<commit_before><?php

namespace Equidea\Router;

use Equidea\Http\Interfaces\RequestInterface;
use Equidea\Router\Traits\CallableTrait;

/**
 * @author      <NAME> <<EMAIL>>
 * @copyright   2016 <NAME>
 * @license     MIT License http://opensource.org/licenses/MIT
 * @package     Equidea\Router
 */
class Route {
    
    use CallableTrait;

    /**
     * @var \Equidea\Http\Interfaces\RequestInterface
     */
    private $request;
    
    /**
     * @var string
     */
    private $pattern;
    
    /**
     * @var array
     */
    private $controller;
    
    /**
     * @var array
     */
    private $methods = [];
    
    /**
     * @var array|null
     */
    private $guard = null;
    
    /**
     * @var string|null
     */
    private $redirect = null;
    
    /**
     * @param   \Equidea\Http\Interfaces\RequestInterface   $request
     * @param   string                                      $pattern
     * @param   array                                       $controller
     * @param   array                                       $methods
     */
    public function __construct(
        RequestInterface $request,
        string $pattern,
        array $controller,
        array $methods
    ) {
        $this->request = $request;
        $this->setPattern($pattern);
        $this->setController($controller);
        $this->setMethods($methods);
    }
    
    /**
     * @return  string
     */
    public function getPattern():string {
        return $this->pattern;
    }
    
    /**
     * @param   string  $pattern
     *
     * @return  void
     */
    public function setPattern(string $pattern) {
        $this->pattern = '/'.trim($pattern, '/');
    }
    
    /**
     * @return  array
     */
    public function getMethods():array {
        return $this->methods;
    }
    
    /**
     * @param   array   $methods
     *
     * @return  void
     */
    public function setMethods(array $methods) {
        $this->methods = $methods;
    }
    
    /**
     * @return  callable
     */
    public function getController():callable
    {
        // Add the namespace prefix for the controller classes to the classname
        $classname = '\\Equidea\\Controller\\'.$this->controller[0];
        return $this->createCallable($classname, $this->controller[1], $this->request);
    }
    
    /**
     * @param   array   $controller
     *
     * @return  void
     */
    public function setController(array $controller) {
        $this->controller = $controller;
    }
    
    /**
     * @return  boolean
     */
    public function hasGuard():bool {
        return !is_null($this->guard);
    }
    
    /**
     * @return  callable
     */
    public function getGuard():callable
    {
        // Add the namespace prefix for the guard classes to the classname
        $classname = '\\Equidea\\Guard\\'.$this->guard[0];
        return $this->createCallable($classname, $this->guard[1], $this->request);
    }
    
    /**
     * @return  string|null
     */
    public function getRedirect() {
        return $this->redirect;
    }
    
    /**
     * @param   array   $guard
     * @param   string  $redirect
     *
     * @return  void
     */
    public function setGuard(array $guard, string $redirect)
    {
        $this->guard = $guard;
        $this->redirect = $redirect;
    }
}<commit_msg>Change Controller creation in Route<commit_after><?php

namespace Equidea\Router;

use Equidea\Http\Interfaces\RequestInterface;
use Equidea\Router\Traits\CallableTrait;

/**
 * @author      <NAME> <<EMAIL>>
 * @copyright   2016 <NAME>
 * @license     MIT License http://opensource.org/licenses/MIT
 * @package     Equidea\Router
 */
class Route {

    /**
     * @var \Equidea\Http\Interfaces\RequestInterface
     */
    private $request;

    /**
     * @var string
     */
    private $pattern;

    /**
     * @var array
     */
    private $controller;

    /**
     * @var array
     */
    private $methods = [];

    /**
     * @var array|null
     */
    private $guard = null;

    /**
     * @var string|null
     */
    private $redirect = null;

    /**
     * @param   \Equidea\Http\Interfaces\RequestInterface   $request
     * @param   string                                      $pattern
     * @param   array                                       $controller
     * @param   array                                       $methods
     */
    public function __construct(
        RequestInterface $request,
        string $pattern,
        array $controller,
        array $methods
    ) {
        $this->request = $request;
        $this->setPattern($pattern);
        $this->setController($controller);
        $this->setMethods($methods);
    }

    /**
     * @return  string
     */
    public function getPattern():string {
        return $this->pattern;
    }

    /**
     * @param   string  $pattern
     *
     * @return  void
     */
    public function setPattern(string $pattern) {
        $this->pattern = '/'.trim($pattern, '/');
    }

    /**
     * @return  array
     */
    public function getMethods():array {
        return $this->methods;
    }

    /**
     * @param   array   $methods
     *
     * @return  void
     */
    public function setMethods(array $methods) {
        $this->methods = $methods;
    }

    /**
     * @return  array
     */
    public function getController():array {
        return $this->controller;
    }

    /**
     * @param   array   $controller
     *
     * @return  void
     */
    public function setController(array $controller) {
        $this->controller = $controller;
    }

    /**
     * @return  boolean
     */
    public function hasGuard():bool {
        return !is_null($this->guard);
    }

    /**
     * @return  array
     */
    public function getGuard():array {
        return $this->guard;
    }
    
    /**
     * @return  string|null
     */
    public function getRedirect() {
        return $this->redirect;
    }

    /**
     * @param   array   $guard
     * @param   string  $redirect
     *
     * @return  void
     */
    public function setGuard(array $guard, string $redirect)
    {
        $this->guard = $guard;
        $this->redirect = $redirect;
    }
}
{'fraction_non_alphanumeric': 0.1317355637767412, 'fraction_numerical': 0.0019301914106482226, 'mean_word_length': 1.5929941618015013, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '312611', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1775, 'n_words': 372}