<commit_before><?php
namespace zaek\engine;

use zaek\kernel\CConfigList;

class CMain
{
    protected $_config = [];
    protected $_conf = null;

    public function __construct()
    {
        /**
         * Создаём список конфигов
         * 1. Из массива
         * 2. Конфиг сайта
         * 3. Конфиг проекта
         * 4. Дефолтный конфиг
         */
        spl_autoload_register([
            $this, 'autoload'
        ]);
    }

    public function conf()
    {
        if ( is_null($this->_conf) ) {
            $this->_conf = new CConfigList();

            $this->_conf->push([
                'fs' => [
                    'root' => $_SERVER["DOCUMENT_ROOT"],
                    'content' => $_SERVER['DOCUMENT_ROOT']. '/content'
                ],
                'template' => [
                    'use_template' => false
                ],
                'request' => [
                    'uri' => @$_SERVER["REQUEST_URI"]
                ]
            ]);
        }

        return $this->_conf;
    }

    public function run()
    {
        if ( $this->conf()->get('template', 'use_template') ) {

        } else {
            $file = $this->pathFromUri($this->conf()->get('request', 'uri'));
            if ( @file_exists($file) ) {
                include $file;
            }
        }
    }

    public function pathFromUri($uri)
    {
        if(strpos($uri, '?') !== false) {
            $uri = substr($uri, 0, strpos($uri, '?'));
        }
        if (substr($uri, -1) == '/') $uri .= 'index.php';

        return $this->conf()->get('fs','content') . $uri;
    }
    /**
     * Basic autoload
     * @param $class
     */
    public function autoload($class)
    {
        @include __DIR__ . '/../../'. str_replace('\\','/',strtolower($class)). '.php';
    }
}<commit_msg>Доступ к объекту файловой системы<commit_after><?php
namespace zaek\engine;

use zaek\kernel\CConfigList;
use zaek\kernel\CFile;

class CMain
{
    protected $_config = [];
    protected $_conf = null;
    protected $_fs = null;

    public function __construct()
    {
        /**
         * Создаём список конфигов
         * 1. Из массива
         * 2. Конфиг сайта
         * 3. Конфиг проекта
         * 4. Дефолтный конфиг
         */
        spl_autoload_register([
            $this, 'autoload'
        ]);
    }

    public function conf()
    {
        if ( is_null($this->_conf) ) {
            $this->_conf = new CConfigList();

            $this->_conf->push([
                'fs' => [
                    'root' => $_SERVER["DOCUMENT_ROOT"],
                    'content' => $_SERVER['DOCUMENT_ROOT']. '/content'
                ],
                'template' => [
                    'use_template' => false,
                    'template_root' => $_SERVER["DOCUMENT_ROOT"],
                    'relative_path' => '',
                ],
                'request' => [
                    'uri' => @$_SERVER["REQUEST_URI"]
                ]
            ]);
        }

        return $this->_conf;
    }

    public function run()
    {
        if ( $this->conf()->get('template', 'use_template') ) {
        } else {
            $file = $this->pathFromUri($this->conf()->get('request', 'uri'));
            if ( @file_exists($file) ) {
                $this->includeFile($file);
            }
        }
    }

    public function includeFile($file)
    {
        include $file;
    }

    public function pathFromUri($uri)
    {
        if(strpos($uri, '?') !== false) {
            $uri = substr($uri, 0, strpos($uri, '?'));
        }
        if (substr($uri, -1) == '/') $uri .= 'index.php';

        return $this->conf()->get('fs','content') . $uri;
    }
    /**
     * Basic autoload
     * @param $class
     */
    public function autoload($class)
    {
        @include __DIR__ . '/../../'. str_replace('\\','/',strtolower($class)). '.php';
    }

    /**
     * @return null|CFile
     */
    public function fs()
    {
        if ( is_null($this->_fs) ) {
            $this->_fs = new CFile($this);
        }

        return $this->_fs;
    }
}
{'fraction_non_alphanumeric': 0.168713163064833, 'fraction_numerical': 0.0029469548133595285, 'mean_word_length': 1.3916617733411627, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2862210', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1247, 'n_words': 224}