<commit_before><?php
namespace MPWAR;

/**
 *
 */
class Route
{
    const GET = "GET";
    const POST = "POST";
    const MINUTES = "minutes";
    const SECONDS = "seconds";
    const HOURS = "hours";
    const MILLISECONDS = "milliseconds";
    const DAYS = "days";
    
    private $url;
    private $method;
    private $expiration;
    private $action;
    private $controller;
    private $responseType;
    
    public function __construct($route, $method = self::GET) {
        $this->url = $route;
        $this->method = $method;
    }
    
    public static function get($route) {
        return new Route($route, self::GET);
    }
    
    public static function post($route) {
        return new Route($route, self::POST);
    }
    
    public function expireAfter($time, $time_unit = self::MILLISECONDS) {
        if ($time_unit == self::MILLISECONDS) {
            $this->expiration = $time;
        } 
        else {
            $this->expiration = $time;
        }
        return $this;
    }
    
    public function execute($action) {
        list($action, $controller) = explode("@", $action);
        if (isset($action) && isset($controller)) {
            $this->action = $action;
            $this->controller = $controller;
        }
        return $this;
    }
    
    public function respondWith($responseType) {
        $this->responseType = $responseType;
        return $this;
    }
    
    public function toArray() {
        return [
            $this->url => [
                $this->method => [
                    'controller' => $this->controller, <commit_msg>changed expiration function and expiration constants.<commit_after><?php
namespace MPWAR;

/**
 *
 */
class Route
{
    const GET = "GET";
    const POST = "POST";
    const MINUTES = 60000;
    const SECONDS = 1000;
    const HOURS = 3600000;
    const MILLISECONDS = 1;
    const DAYS = 86400000;

    const DEFAULT_EXPIRATION = 500;
    
    private $url;
    private $method;
    private $expiration;
    private $action;
    private $controller;
    private $responseType;
    
    public function __construct($route, $method = self::GET) {
        $this->url = $route;
        $this->method = $method;
    }
    
    public static function get($route) {
        return new Route($route, self::GET);
    }
    
    public static function post($route) {
        return new Route($route, self::POST);
    }
    
    private function isValidTimeUnit($time_unit) {
        return $time_unit === self::DAYS ||
               $time_unit === self::HOURS ||
               $time_unit === self::MINUTES ||
               $time_unit === self::SECONDS ||
               $time_unit === self::MILLISECONDS;
    }

    public function expireAfter($time, $time_unit = self::MILLISECONDS) {
        if($this->isValidTimeUnit($time_unit)) {
            $this->expiration = $time * $time_unit;
        } else {
            $this->expiration = self::DEFAULT_EXPIRATION;
        }
        return $this;
    }
    
    public function execute($action) {
        list($action, $controller) = explode("@", $action);
        if (isset($action) && isset($controller)) {
            $this->action = $action;
            $this->controller = $controller;
        }
        return $this;
    }
    
    public function respondWith($responseType) {
        $this->responseType = $responseType;
        return $this;
    }
    
    public function toArray() {
        return [
            $this->url => [
                $this->method => [
                    'controller' => $this->controller, 
{'fraction_non_alphanumeric': 0.1326416152551879, 'fraction_numerical': 0.007851934941110488, 'mean_word_length': 1.9949622166246852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '1012543', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1039, 'n_words': 239}