<commit_before><?php
namespace Karen\Framework;

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Pimple\Container;
use Relay\RelayBuilder;
use Karen\Application;
use Karen\Controller;
use Karen\Templatable;

class Karen2 extends Application
{
    protected $c;
    protected $route;

    public function container()
    {
        $this->c = new Container();
        $this->c['controller'] = new Controller($this->request, $this->response);
        $this->c['dispatcher'] = function($c) {
            return \FastRoute\simpleDispatcher($c['handlers']);
        };
    }
    public function middleware()
    {
    }

    public function route()
    {
        $this->c['handlers'] = function($c) {
            return $this->handlers();
        };
        $dispatcher = $this->c['dispatcher'];
        $serverParams = $this->request->getServerParams();
        $uri = $serverParams['REQUEST_URI'];
        $method = $serverParams['REQUEST_METHOD'];
        $this->route = $dispatcher->dispatch($method, $uri);
    }

    public function response(){
        switch ($this->route[0]) {
            case \FastRoute\Dispatcher::NOT_FOUND:
                echo "Not Found\n";
                break;
            case \FastRoute\Dispatcher::FOUND:
                $handler = $this->route[1];
                $args = $this->route[2];
                $this->addQueue('action', $this->c['controller']->actionQueue($handler, $args));
                break;
            default:
                echo "unknown";
        }
        // apply middleware and get response
        $relayBuilder = new RelayBuilder();
        $relay = $relayBuilder->newInstance($this->getQueues());
        $this->response = $relay($this->request, $this->response);
    }
}<commit_msg>Fix refactor FastRoute logic to simple<commit_after><?php
namespace Karen\Framework;

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Pimple\Container;
use Relay\RelayBuilder;
use Karen\Application;
use Karen\Controller;
use Karen\Templatable;

class Karen2 extends Application
{
    protected $c;
    protected $route;

    public function container()
    {
        $this->c = new Container();
        $this->c['controller'] = new Controller($this->request, $this->response);
        $this->c['dispatcher'] = function($c) {
            return \FastRoute\simpleDispatcher($c['handlers']);
        };
    }
    public function middleware()
    {
    }

    public function route()
    {
        $this->c['handlers'] = function($c) {
            return $this->handlers();
        };
        $dispatcher = $this->c['dispatcher'];
        $this->route = $dispatcher->dispatch($this->request->getMethod(), $this->request->getUri());
    }

    public function response(){
        switch ($this->route[0]) {
            case \FastRoute\Dispatcher::NOT_FOUND:
                echo "Not Found\n";
                break;
            case \FastRoute\Dispatcher::FOUND:
                $handler = $this->route[1];
                $args = $this->route[2];
                $this->addQueue('action', $this->c['controller']->actionQueue($handler, $args));
                break;
            default:
                throw new \LogicException('Should not reach this point');
        }
        // apply middleware and get response
        $relayBuilder = new RelayBuilder();
        $relay = $relayBuilder->newInstance($this->getQueues());
        $this->response = $relay($this->request, $this->response);
    }
}
{'fraction_non_alphanumeric': 0.14705882352941177, 'fraction_numerical': 0.002240896358543417, 'mean_word_length': 2.37204910292729, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '6781344', 'n_tokens_mistral': 1004, 'n_tokens_neox': 976, 'n_words': 206}