<commit_before><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\FrameworkBundle\Profiler;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseFromExceptionEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * ProfilerListener collects data for the current request by listening to the filterCoreResponse event.
 *
 * @author <NAME> <<EMAIL>>
 */
class ProfilerListener
{
    protected $container;
    protected $exception;
    protected $onlyException;
    protected $matcher;

    /**
     * Constructor.
     *
     * @param ContainerInterface      $container     A ContainerInterface instance
     * @param RequestMatcherInterface $matcher       A RequestMatcher instance
     * @param Boolean                 $onlyException true if the profiler only collects data when an exception occurs, false otherwise
     */
    public function __construct(ContainerInterface $container, RequestMatcherInterface $matcher = null, $onlyException = false)
    {
        $this->container = $container;
        $this->matcher = $matcher;
        $this->onlyException = $onlyException;
    }

    /**
     * Handles the onCoreRequest event
     *
     * This method initialize the profiler to be able to get it as a scoped
     * service when filterCoreResponse() will collect the sub request
     *
     * @param GetResponseEvent $event A GetResponseEvent instance
     */
    public function onCoreRequest(GetResponseEvent $event)
    {
        $this->container->get('profiler');
    }

    /**
     * Handles the onCoreException event.
     *
     * @param GetResponseFromExceptionEvent $event A GetResponseFromExceptionEvent instance
     */
    public function onCoreException(GetResponseFromExceptionEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $this->exception = $event->getException();
    }

    /**
     * Handles the filterCoreResponse event.
     *
     * @param FilterResponseEvent $event A FilterResponseEvent instance
     */
    public function filterCoreResponse(FilterResponseEvent $event)
    {
        if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
            return $response;
        }<commit_msg>[FrameworkBundle] Fixed typo in ProfileListener<commit_after><?php

/*
 * This file is part of the Symfony package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\FrameworkBundle\Profiler;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * ProfilerListener collects data for the current request by listening to the filterCoreResponse event.
 *
 * @author <NAME> <<EMAIL>>
 */
class ProfilerListener
{
    protected $container;
    protected $exception;
    protected $onlyException;
    protected $matcher;

    /**
     * Constructor.
     *
     * @param ContainerInterface      $container     A ContainerInterface instance
     * @param RequestMatcherInterface $matcher       A RequestMatcher instance
     * @param Boolean                 $onlyException true if the profiler only collects data when an exception occurs, false otherwise
     */
    public function __construct(ContainerInterface $container, RequestMatcherInterface $matcher = null, $onlyException = false)
    {
        $this->container = $container;
        $this->matcher = $matcher;
        $this->onlyException = $onlyException;
    }

    /**
     * Handles the onCoreRequest event
     *
     * This method initialize the profiler to be able to get it as a scoped
     * service when filterCoreResponse() will collect the sub request
     *
     * @param GetResponseEvent $event A GetResponseEvent instance
     */
    public function onCoreRequest(GetResponseEvent $event)
    {
        $this->container->get('profiler');
    }

    /**
     * Handles the onCoreException event.
     *
     * @param GetResponseForExceptionEvent $event A GetResponseForExceptionEvent instance
     */
    public function onCoreException(GetResponseForExceptionEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $this->exception = $event->getException();
    }

    /**
     * Handles the filterCoreResponse event.
     *
     * @param FilterResponseEvent $event A FilterResponseEvent instance
     */
    public function filterCoreResponse(FilterResponseEvent $event)
    {
        if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
            return $response;
        }
{'fraction_non_alphanumeric': 0.09001457725947522, 'fraction_numerical': 0.0, 'mean_word_length': 3.2916340891321343, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, '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': '3402213', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1391, 'n_words': 392}