<commit_before><?php

namespace Scarlett;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Scarlett\Event\ResponseEvent;
use Scarlett\Event\KernelEvents;

class Kernel
{
    private $dispatcher;
    private $matcher;
    private $resolver;

    public function __construct(EventDispatcher $dispatcher, UrlMatcherInterface $matcher, ControllerResolverInterface $resolver)
    {
        $this->dispatcher = $dispatcher;
        $this->matcher = $matcher;
        $this->resolver = $resolver;
    }

    public function handle(Request $request)
    {
        try{
            $request->attributes->add($this->matcher->match($request->getPathInfo()));

            $controller = $this->resolver->getController($request);
            $arguments = $this->resolver->getArguments($request, $controller);

            $response = call_user_func_array($controller, $arguments);
        }catch(ResourceNotFoundException $e) {
            $response = new Response('Not found', 404);
        }catch(\Exception $e){
            $response = new Response('[Scarlett Kernel Exception] '.$e->getMessage(), 500);
            $this->dispatcher->dispatch(KernelEvents::EXCEPTION, new ExceptionEvent($request, $e));
        }
        $this->dispatcher->dispatch(KernelEvents::RESPONSE, new ResponseEvent($request, $response));

        return $response;
    }
    
}<commit_msg>Change EventDispatcher use to EventDispatcherInterface<commit_after><?php

namespace Scarlett;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Scarlett\Event\ResponseEvent;
use Scarlett\Event\KernelEvents;

class Kernel
{
    private $dispatcher;
    private $matcher;
    private $resolver;

    public function __construct(EventDispatcherInterface $dispatcher, UrlMatcherInterface $matcher, ControllerResolverInterface $resolver)
    {
        $this->dispatcher = $dispatcher;
        $this->matcher = $matcher;
        $this->resolver = $resolver;
    }

    public function handle(Request $request)
    {
        try{
            $request->attributes->add($this->matcher->match($request->getPathInfo()));

            $controller = $this->resolver->getController($request);
            $arguments = $this->resolver->getArguments($request, $controller);

            $response = call_user_func_array($controller, $arguments);
        }catch(ResourceNotFoundException $e) {
            $response = new Response('Not found', 404);
        }catch(\Exception $e){
            $response = new Response('[Scarlett Kernel Exception] '.$e->getMessage(), 500);
            $this->dispatcher->dispatch(KernelEvents::EXCEPTION, new ExceptionEvent($request, $e));
        }
        $this->dispatcher->dispatch(KernelEvents::RESPONSE, new ResponseEvent($request, $response));

        return $response;
    }
    
}
{'fraction_non_alphanumeric': 0.11963281018655611, 'fraction_numerical': 0.0035534498075214687, 'mean_word_length': 3.860431654676259, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '2608060', 'n_tokens_mistral': 912, 'n_tokens_neox': 886, 'n_words': 166}