<commit_before><?php

namespace Mwyatt\Core\Http;

class Kernel implements \Mwyatt\Core\Http\KernelInterface
{
    private $services;
    private $middleware = [];
    private $middlewarePost = [];

    
    public function __construct()
    {
        $this->services = new \Pimple\Container;
    }


    public function setRoutes(array $routes)
    {
        $this->services['Routes'] = $routes;
    }


    public function setMiddleware($config)
    {
        $this->middleware = $config;
    }


    public function setSettings(array $settings)
    {
        $config = $this->services['Config'];
        foreach ($settings as $key => $value) {
            $config->setSetting($key, $value);
        }
    }


    public function setServicesOptional()
    {
        $this->services['ErrorHandler'] = function ($services) {
            $config = $services['Config'];
            $log = new \Monolog\Logger('system');
            if ($config->getSetting('core.displayErrors')) {
                // ini_set('display_errors', 1);
                // ini_set('display_startup_errors', 1);
                // error_reporting(E_ALL);
                $log->pushHandler(new \Monolog\Handler\BrowserConsoleHandler);
            }
            $log->pushHandler(new \Monolog\Handler\StreamHandler($services['ProjectPath'] . 'error.txt', \Monolog\Logger::DEBUG));
            return $log;
        };

        \Monolog\ErrorHandler::set($this->services['ErrorHandler']);

        $this->services['ModelFactory'] = function ($services) {
            $config = $services['Config'];
            $modelFactory = new \Mwyatt\Core\Factory\Model;
            $modelFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Model\\');
            return $modelFactory;
        };

        $this->services['IteratorFactory'] = function ($services) {
            $config = $services['Config'];
            $iteratorFactory = new \Mwyatt\Core\Factory\Iterator;
            $iteratorFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Iterator\\');
            return $iteratorFactory;
        };

        $this->services['MapperFactory'] = function ($services) {
            $config = $services['Config'];
            $mapperFactory = new \Mwyatt\Core\Factory\Mapper(
                $services['Database'],
                $services['ModelFactory'],
                $services['IteratorFactory']
            );
            $mapperFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Mapper\\');<commit_msg>error handler set method change<commit_after><?php

namespace Mwyatt\Core\Http;

class Kernel implements \Mwyatt\Core\Http\KernelInterface
{
    private $services;
    private $middleware = [];
    private $middlewarePost = [];

    
    public function __construct()
    {
        $this->services = new \Pimple\Container;
    }


    public function setRoutes(array $routes)
    {
        $this->services['Routes'] = $routes;
    }


    public function setMiddleware($config)
    {
        $this->middleware = $config;
    }


    public function setSettings(array $settings)
    {
        $config = $this->services['Config'];
        foreach ($settings as $key => $value) {
            $config->setSetting($key, $value);
        }
    }


    public function setServicesOptional()
    {
        $this->services['ErrorHandler'] = function ($services) {
            $config = $services['Config'];
            $log = new \Monolog\Logger('system');
            if ($config->getSetting('core.displayErrors')) {
                // ini_set('display_errors', 1);
                // ini_set('display_startup_errors', 1);
                // error_reporting(E_ALL);
                $log->pushHandler(new \Monolog\Handler\BrowserConsoleHandler);
            }
            $log->pushHandler(new \Monolog\Handler\StreamHandler($services['ProjectPath'] . 'error.txt', \Monolog\Logger::DEBUG));
            return $log;
        };

        \Monolog\ErrorHandler::register($this->services['ErrorHandler']);

        $this->services['ModelFactory'] = function ($services) {
            $config = $services['Config'];
            $modelFactory = new \Mwyatt\Core\Factory\Model;
            $modelFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Model\\');
            return $modelFactory;
        };

        $this->services['IteratorFactory'] = function ($services) {
            $config = $services['Config'];
            $iteratorFactory = new \Mwyatt\Core\Factory\Iterator;
            $iteratorFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Iterator\\');
            return $iteratorFactory;
        };

        $this->services['MapperFactory'] = function ($services) {
            $config = $services['Config'];
            $mapperFactory = new \Mwyatt\Core\Factory\Mapper(
                $services['Database'],
                $services['ModelFactory'],
                $services['IteratorFactory']
            );
            $mapperFactory->setDefaultNamespace($config->getSetting('projectBaseNamespace') . 'Mapper\\');
{'fraction_non_alphanumeric': 0.14623655913978495, 'fraction_numerical': 0.0007820136852394917, 'mean_word_length': 2.332899022801303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '5244714', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1314, 'n_words': 217}