<commit_before><?php

namespace Picon\Lib;

use Picon\Lib\Config    as Config;

class Router{

    public  $routesRules;
    
    public function __construct(){
        $this->loadRules();
    }

    public function route(){
        $route  =   array();

        $contentUri     =   $_SERVER["REQUEST_URI"];
        if($_SERVER["QUERY_STRING"]){
            $contentUri =  substr($contentUri, 0, - (strlen($_SERVER["QUERY_STRING"]) + 1)); 
        }


        foreach($this->routesRules as $ruleSet){
            if(preg_match("/^" . preg_quote($ruleSet["pattern"], "/") . "(\/.*)?$/", $contentUri)){
                !(isset($ruleSet["action"]) && $ruleSet["action"]) && $ruleSet["action"] = "index";
                !(isset($ruleSet["params"]) && $ruleSet["params"]) && $ruleSet["params"] = array();

                $params             =   array();
                $unhandled_params   =   array();

                $paramsUri          =   (isset($ruleSet["params"]) && $ruleSet["params"])
                                        ?   explode("/", trim(substr($contentUri, strlen($ruleSet["pattern"])), "/"))
                                        :   array();


                foreach($ruleSet["params"] as $number => $param){
                    $params[$param] =   (isset($paramsUri[$number]))
                                            ?   $paramsUri[$number]
                                            :   "";
                }

                count($paramsUri) > count($ruleSet["params"]) && $unhandled_params =   array_chunk($paramsUri, (count($paramsUri) - count($params)), true)[1];

                $route  =   array(<commit_msg>[wip] Adding some fixes on router<commit_after><?php

namespace Picon\Lib;

use Picon\Lib\Config    as Config;

class Router{

    public  $routesRules;
    
    public function __construct(){
        $this->loadRules();
    }

    public function route(){
        $route  =   array();

        $contentUri     =   $_SERVER["REQUEST_URI"];
        if($_SERVER["QUERY_STRING"]){
            $contentUri =  substr($contentUri, 0, - (strlen($_SERVER["QUERY_STRING"]) + 1)); 
        }


        foreach($this->routesRules as $ruleSet){
            if(preg_match("/^" . preg_quote($ruleSet["pattern"], "/") . "(\/.*)?$/", $contentUri)){
                !(isset($ruleSet["action"]) && $ruleSet["action"]) && $ruleSet["action"] = "index";
                !(isset($ruleSet["params"]) && $ruleSet["params"]) && $ruleSet["params"] = array();

                $params             =   array();
                $unhandled_params   =   array();

                $paramsUriString    =   trim(substr($contentUri, strlen($ruleSet["pattern"])), "/");
                $paramsUri          =   (isset($ruleSet["params"]) && $ruleSet["params"] && $paramsUriString)
                                        ?   explode("/", $paramsUriString)
                                        :   array();


                foreach($ruleSet["params"] as $number => $param){
                    isset($paramsUri[$number]) && $params[$param] =   $paramsUri[$number];
                }

                count($paramsUri) > count($ruleSet["params"]) && $unhandled_params =   array_chunk($paramsUri, (count($paramsUri) - count($params)), true)[1];

                $route  =   array(
{'fraction_non_alphanumeric': 0.1785279805352798, 'fraction_numerical': 0.0018248175182481751, 'mean_word_length': 1.801533219761499, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5236330', 'n_tokens_mistral': 909, 'n_tokens_neox': 864, 'n_words': 145}