<commit_before><?php
namespace QuimCalpe\Router;

use QuimCalpe\Router\Route\Route;
use QuimCalpe\Router\Route\ParsedRoute;

class Router
{
    private $trailing_slash_check = true;
    private $routes = [];
    private $route_names = [];
    private $regexp_map = [
        '/\{([A-Za-z]\w*)\}/' => '(?<$1>[^/]+)',
        '/\{([A-Za-z]\w*):word\}/' => '(?<$1>\w+)',
        '/\{([A-Za-z]\w*):number\}/' => '(?<$1>\d+)',
        '/\{([A-Za-z]\w*):slug\}/' => '(?<$1>[A-Za-z0-9_-]+)',
        '/\{([A-Za-z]\w*):([^}]+)\}/' => '(?<$1>$2)',
        '/\//' => '\/'
    ];
    private static $parsed_regexp = []; // cache

    /**
     * Creates a new Router.
     *
     * @param array $routes
     *      (Optional) Associative array of URIs to handlers.
     *      URIs take the form of [VERB1|VERB2]/[uri] or /[uri] (the latter
     *      assumes a verb of GET). Handlers take the form of
     *      ClassName::methodName or ClassName (in the latter case, a
     *      methodName of index is assumed).
     */
    public function __construct(array $routes = [])
    {
        foreach ($routes as $uri => $route) {
            if ($route instanceof Route) {
                $this->add($route);
            } else {
                @trigger_error('Calling the constructor with an associative array is deprecated since version 0.4 and will be removed in 1.0. Use an array of Route value objects instead.', E_USER_DEPRECATED);
                if (preg_match_all("/^(\[([A-Z|]+)\])?\/?(.*)/i", $uri, $matches, PREG_SET_ORDER)) {
                    $methods = explode("|", strtoupper($matches[0][2]));
                    if (count($methods) === 1 && trim($methods[0]) === "") {
                        $methods[0] = "GET";
                    }
                    foreach ($methods as $method) {
                        if (!isset($this->routes[$method])) {
                            $this->routes[$method] = [];
                        }
                        $this->routes[$method]["/".$matches[0][3]] = $route;
                    }
                }
            }<commit_msg>Remove deprecated associative array as constructor parameter<commit_after><?php
namespace QuimCalpe\Router;

use QuimCalpe\Router\Route\Route;
use QuimCalpe\Router\Route\ParsedRoute;

class Router
{
    private $trailing_slash_check = true;
    private $routes = [];
    private $route_names = [];
    private $regexp_map = [
        '/\{([A-Za-z]\w*)\}/' => '(?<$1>[^/]+)',
        '/\{([A-Za-z]\w*):word\}/' => '(?<$1>\w+)',
        '/\{([A-Za-z]\w*):number\}/' => '(?<$1>\d+)',
        '/\{([A-Za-z]\w*):slug\}/' => '(?<$1>[A-Za-z0-9_-]+)',
        '/\{([A-Za-z]\w*):([^}]+)\}/' => '(?<$1>$2)',
        '/\//' => '\/'
    ];
    private static $parsed_regexp = []; // cache

    /**
     * Creates a new Router.
     *
     * @param Route[] $routes
     *      (Optional) Array of Route value objects to create.
     *
     * @throws \RunTimeException
     *      Thrown if array not contains Router instances.
     */
    public function __construct(array $routes = [])
    {
        foreach ($routes as $uri => $route) {
            if ($route instanceof Route) {
                $this->add($route);
            } else {
                throw new \RunTimeException("An array of ".Route::class." instances is required since 1.0.0");
            }
{'fraction_non_alphanumeric': 0.21175764847030593, 'fraction_numerical': 0.009598080383923215, 'mean_word_length': 1.828668363019508, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 32, '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': '7507282', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1107, 'n_words': 232}