<commit_before><?php

/**
 * Router module
 *
 * Copyright 2016-2019 秋水之冰 <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace init;

use core\handler\factory;

class router extends factory
{
    //Router symbols
    const SYMBOL = ['-' => '/', '.' => '-'];

    /**
     * router constructor.
     */
    public function __construct()
    {
        if (false === $start = strpos($_SERVER['REQUEST_URI'], '/', 1)) {
            return;
        }

        $uri = explode('/', substr($_SERVER['REQUEST_URI'], $start + 1));
        $cnt = count($uri);

        for ($i = 0; $i < $cnt; ++$i) {
            if (0 === $i) {
                parent::$cmd = strtr($uri[$i], self::SYMBOL);
            } else {
                parent::$data[$uri[$i]] = $uri[++$i] ?? null;
            }
        }
    }
}<commit_msg>Using $_SERVER['PATH_INFO'] instead of $_SERVER['REQUEST_URI']<commit_after><?php

/**
 * Router module
 *
 * Copyright 2016-2019 秋水之冰 <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace init;

use core\handler\factory;

class router extends factory
{
    //Router symbols
    const SYMBOL = ['-' => '/', '.' => '-'];

    /**
     * router constructor.
     */
    public function __construct()
    {
        //Check PATH INFO
        if (!isset($_SERVER['PATH_INFO'])) {
            return;
        }

        //Cut off first slash
        $path_info = substr($_SERVER['PATH_INFO'], 1);

        //Get URI units
        $unit = false !== strpos($path_info, '/') ? array_filter(explode('/', $path_info)) : [$path_info];

        //Get CMD
        parent::$cmd = strtr(array_shift($unit), self::SYMBOL);

        //Map param
        $cnt = count($unit);
        for ($i = 0; $i < $cnt; ++$i) {
            parent::$data[$unit[$i]] = $unit[++$i] ?? null;
        }
    }
}
{'fraction_non_alphanumeric': 0.14664310954063603, 'fraction_numerical': 0.01060070671378092, 'mean_word_length': 2.4864532019704435, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '569606', 'n_tokens_mistral': 837, 'n_tokens_neox': 808, 'n_words': 277}