<commit_before><?php
namespace Aura\Web_Kernel;

class WebKernel extends ProjectKernel
{
    public function __invoke()
    {
        parent::__invoke();
        
        $this->logger     = $this->di->get('logger');
        $this->request    = $this->di->get('web_request');
        $this->response   = $this->di->get('web_response');
        $this->router     = $this->di->get('web_router');
        $this->dispatcher = $this->di->get('web_dispatcher');
        
        $this->request();
        $this->response();
    }
    
    protected function request()
    {
        $this->logger->debug(__METHOD__ . ' routing');
        
        $route = $this->router->match(
            $this->request->url->get(PHP_URL_PATH),
            $this->request->server->get()
        );
        
        if ($route) {
            $this->request->params->set($route->params);
        } else {
            $this->logger->debug(__METHOD__ . ' routing: no route');
            $this->request->params->set(array(
                'controller' => 'no_route',
            ));
        }

        $routes = $this->router->getLog();
        if (! $routes) {
            $this->logger->debug(__METHOD__ . ' routing: no routes in router');
        } else {
            foreach ($routes as $route) {
                foreach ($route->debug as $message) {
                    $name = $route->name
                          ? $route->name
                          : $this->request->method->get() . ' ' . $route->path;
                    $message = __METHOD__ . " routing: $name $message";
                    $this->logger->debug($message);
                }
            }
        }
        
        try {
            $this->logger->debug(__METHOD__ . ' dispatch');
            $this->dispatcher->__invoke($this->request->params->get());
        } catch (\Aura\Dispatcher\Exception\ObjectNotDefined $e) {
            $this->logger->debug(__METHOD__ . ' dispatch: no controller');
            $dispatcher->__invoke(array(
                'controller' => 'no_controller',
            ));
        }
    }
    
    protected function response()
    {
        $this->logger->debug(__METHOD__);
        
        // send the response status line
        header(
            $this->response->status->get(),
            true,
            $this->response->status->getCode()
        );
        
        // send non-cookie headers
        foreach ($this->response->headers->get() as $label => $value) {
            header($label, $value);
        }
        
        // send cookies
        foreach ($this->response->cookies->get() as $name => $cookie) {
            setcookie(
                $name,
                $cookie['value'],
                $cookie['expire'],
                $cookie['path'],
                $cookie['domain'],
                $cookie['secure'],
                $cookie['httponly']
            );
        }
        
        // send content, and done!
        echo $this->response->content->get();
    }
}
<commit_msg>use new router method getDebug() instead of old getLog()<commit_after><?php
namespace Aura\Web_Kernel;

class WebKernel extends ProjectKernel
{
    public function __invoke()
    {
        parent::__invoke();
        
        $this->logger     = $this->di->get('logger');
        $this->request    = $this->di->get('web_request');
        $this->response   = $this->di->get('web_response');
        $this->router     = $this->di->get('web_router');
        $this->dispatcher = $this->di->get('web_dispatcher');
        
        $this->request();
        $this->response();
    }
    
    protected function request()
    {
        $this->logger->debug(__METHOD__ . ' routing');
        
        $route = $this->router->match(
            $this->request->url->get(PHP_URL_PATH),
            $this->request->server->get()
        );
        
        if ($route) {
            $this->request->params->set($route->params);
        } else {
            $this->logger->debug(__METHOD__ . ' routing: no route');
            $this->request->params->set(array(
                'controller' => 'no_route',
            ));
        }

        $routes = $this->router->getDebug();
        if (! $routes) {
            $this->logger->debug(__METHOD__ . ' routing: no routes in router');
        } else {
            foreach ($routes as $route) {
                foreach ($route->debug as $message) {
                    $name = $route->name
                          ? $route->name
                          : $this->request->method->get() . ' ' . $route->path;
                    $message = __METHOD__ . " routing: $name $message";
                    $this->logger->debug($message);
                }
            }
        }
        
        try {
            $this->logger->debug(__METHOD__ . ' dispatch');
            $this->dispatcher->__invoke($this->request->params->get());
        } catch (\Aura\Dispatcher\Exception\ObjectNotDefined $e) {
            $this->logger->debug(__METHOD__ . ' dispatch: no controller');
            $dispatcher->__invoke(array(
                'controller' => 'no_controller',
            ));
        }
    }
    
    protected function response()
    {
        $this->logger->debug(__METHOD__);
        
        // send the response status line
        header(
            $this->response->status->get(),
            true,
            $this->response->status->getCode()
        );
        
        // send non-cookie headers
        foreach ($this->response->headers->get() as $label => $value) {
            header($label, $value);
        }
        
        // send cookies
        foreach ($this->response->cookies->get() as $name => $cookie) {
            setcookie(
                $name,
                $cookie['value'],
                $cookie['expire'],
                $cookie['path'],
                $cookie['domain'],
                $cookie['secure'],
                $cookie['httponly']
            );
        }
        
        // send content, and done!
        echo $this->response->content->get();
    }
}

{'fraction_non_alphanumeric': 0.1611890999174236, 'fraction_numerical': 0.0, 'mean_word_length': 1.4488475535786494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 163, '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': '1154897', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1594, 'n_words': 270}