<commit_before><?php

namespace Perfumer;

use Perfumer\Container\Core as Container;
use Perfumer\Controller\HTTPException;

class Request
{
    protected $container;

    public $url;
    public $controller;
    public $method;
    public $template;
    public $css;
    public $js;

    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    public function execute($url = null, $method = null, array $args = [])
    {
        if ($url === null)
        {
            $url = ($_SERVER['PATH_INFO'] !== '/') ? $_SERVER['PATH_INFO'] : $this->container->p('app.default_url');
        }

        $url = trim($url, '/');
        $path = explode('/', $url);

        $this->url = $url;
        $this->method = ($method === null) ? strtolower($_SERVER['REQUEST_METHOD']) : $method;
        $this->template = $url . '/' . $this->method . '.twig';
        $this->css = $url . '/' . $this->method . '.css';
        $this->js = $url . '/' . $this->method . '.js';
        $this->controller = 'App\\Controller\\' . implode('\\', array_map('ucfirst', $path)) . 'Controller';

        try
        {
            $reflection_class = new \ReflectionClass($this->controller);
        }
        catch (\ReflectionException $e)
        {
            throw new HTTPException("Controller '{$this->controller}' does not exist", 404);
        }

        $request = $this;
        $response = $this->container->s('response');
        $controller = $reflection_class->newInstance($this->container, $request, $response);

        return $reflection_class->getMethod('execute')->invoke($controller, $this->method, $args);
    }
}<commit_msg>Getters and setters for Request class<commit_after><?php

namespace Perfumer;

use Perfumer\Container\Core as Container;
use Perfumer\Controller\Exception\HTTPException;

class Request
{
    protected $container;

    public $url;
    public $controller;
    public $method;
    public $template;
    public $css;
    public $js;

    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    public function execute($url = null, $method = null, array $args = [])
    {
        if ($url === null)
        {
            $url = ($_SERVER['PATH_INFO'] !== '/') ? $_SERVER['PATH_INFO'] : $this->container->p('app.default_url');
        }

        $url = trim($url, '/');
        $path = explode('/', $url);

        $this->setURL($url);
        $this->setMethod(($method === null) ? strtolower($_SERVER['REQUEST_METHOD']) : $method);
        $this->setTemplate($url . '/' . $this->method . '.twig');
        $this->setCSS($url . '/' . $this->method . '.css');
        $this->setJS($url . '/' . $this->method . '.js');
        $this->setController('App\\Controller\\' . implode('\\', array_map('ucfirst', $path)) . 'Controller');

        try
        {
            $reflection_class = new \ReflectionClass($this->getController());
        }
        catch (\ReflectionException $e)
        {
            throw new HTTPException("Controller '{$this->getController()}' does not exist", 404);
        }

        $request = $this;
        $response = $this->container->s('response');
        $controller = $reflection_class->newInstance($this->container, $request, $response);

        return $reflection_class->getMethod('execute')->invoke($controller, $this->getMethod(), $args);
    }

    public function getURL()
    {
        return $this->url;
    }

    public function setURL($url)
    {
        $this->url = $url;
        return $this;
    }

    public function getController()
    {
        return $this->controller;
    }

    public function setController($controller)
    {
        $this->controller = $controller;
        return $this;
    }

    public function getMethod()
    {
        return $this->method;
    }

    public function setMethod($method)
    {
        $this->method = $method;
        return $this;
    }

    public function getTemplate()
    {
        return $this->template;
    }

    public function setTemplate($template)
    {
        $this->template = $template;
        return $this;
    }

    public function getCSS()
    {
        return $this->css;
    }

    public function setCSS($css)
    {
        $this->css = $css;
        return $this;
    }

    public function getJS()
    {
        return $this->js;
    }

    public function setJS($js)
    {
        $this->js = $js;
        return $this;
    }
}
{'fraction_non_alphanumeric': 0.16700291414481058, 'fraction_numerical': 0.0013449899125756557, 'mean_word_length': 2.240377632534495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, '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': '865013', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1297, 'n_words': 277}