<commit_before><?php

namespace CarlBennett\API\Controllers;

use \CarlBennett\API\Libraries\Common;
use \CarlBennett\API\Libraries\Controller;
use \CarlBennett\API\Libraries\Exceptions\UnspecifiedViewException;
use \CarlBennett\API\Libraries\Router;
use \CarlBennett\API\Models\Status as StatusModel;
use \CarlBennett\API\Views\StatusJSON as StatusJSONView;
use \CarlBennett\API\Views\StatusPlain as StatusPlainView;
use \DateTime;
use \DateTimeZone;

class Status extends Controller {

  public function run(Router &$router) {
    switch ($router->getRequestPathExtension()) {
      case "json": case "":
        $view = new StatusJSONView();
      break;
      case "txt":
        $view = new StatusPlainView();
      break;
      default:
        throw new UnspecifiedViewException();
    }
    $model = new StatusModel();
    $this->getStatus($model);
    ob_start();
    $view->render($model);
    $router->setResponseCode(200);
    $router->setResponseTTL(300);
    $router->setResponseHeader("Content-Type", $view->getMimeType());
    $router->setResponseContent(ob_get_contents());
    ob_end_clean();
  }

  protected function getStatus(StatusModel &$model) {
    $model->remote_address   = getenv("REMOTE_ADDR");
    $model->remote_geoinfo   = geoip_record_by_name($model->remote_address);
    $model->timestamp        = new DateTime("now", new DateTimeZone("UTC"));
    $model->timestamp_format = "Y-m-d H:i:s T";
    $model->version_info     = Common::versionProperties();
    return true;
  }

}<commit_msg>Use RFC-2822 timestamp format<commit_after><?php

namespace CarlBennett\API\Controllers;

use \CarlBennett\API\Libraries\Common;
use \CarlBennett\API\Libraries\Controller;
use \CarlBennett\API\Libraries\Exceptions\UnspecifiedViewException;
use \CarlBennett\API\Libraries\Router;
use \CarlBennett\API\Models\Status as StatusModel;
use \CarlBennett\API\Views\StatusJSON as StatusJSONView;
use \CarlBennett\API\Views\StatusPlain as StatusPlainView;
use \DateTime;
use \DateTimeZone;

class Status extends Controller {

  public function run(Router &$router) {
    switch ($router->getRequestPathExtension()) {
      case "json": case "":
        $view = new StatusJSONView();
      break;
      case "txt":
        $view = new StatusPlainView();
      break;
      default:
        throw new UnspecifiedViewException();
    }
    $model = new StatusModel();
    $this->getStatus($model);
    ob_start();
    $view->render($model);
    $router->setResponseCode(200);
    $router->setResponseTTL(300);
    $router->setResponseHeader("Content-Type", $view->getMimeType());
    $router->setResponseContent(ob_get_contents());
    ob_end_clean();
  }

  protected function getStatus(StatusModel &$model) {
    $model->remote_address   = getenv("REMOTE_ADDR");
    $model->remote_geoinfo   = geoip_record_by_name($model->remote_address);
    $model->timestamp        = new DateTime("now", new DateTimeZone("UTC"));
    $model->timestamp_format = "r";
    $model->version_info     = Common::versionProperties();
    return true;
  }

}
{'fraction_non_alphanumeric': 0.13690085357846357, 'fraction_numerical': 0.005252790544977019, 'mean_word_length': 4.003284072249589, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2188227', 'n_tokens_mistral': 974, 'n_tokens_neox': 951, 'n_words': 175}