<commit_before><?php

namespace AdrienBrault\StatsDCollector\Provider;

use AdrienBrault\StatsDCollector\ParameterProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;

/**
 * @author <NAME> <<EMAIL>>
 */
class SymfonyRequestProvider implements ParameterProviderInterface
{
    /**
     * @var Request|null
     */
    private $request;

    public function __construct(Request $request = null)
    {
        $this->request = $request;
    }

    public function setRequest(Request $request)
    {
        $this->request = $request;
    }

    public function onKernelRequest(GetResponseEvent $event)
    {
        $this->setRequest($event->getRequest());
    }

    /**
     * {@inheritdoc}
     */
    public function getParameters()
    {
        $method = null;
        $format = null;
        $scheme = null;
        $ajax = null;
        $locale = null;
        $route = null;

        if (null !== $this->request) {
            $method = strtolower($this->request->getMethod());
            $format = $this->request->getRequestFormat();
            $scheme = $this->request->getScheme();
            $ajax = $this->request->isXmlHttpRequest() ? 'ajax' : 'not_ajax';
            $locale = $this->request->getLocale();
            $route = $this->request->attributes->get('_route');
        }
<commit_msg>Fix SymfonyRequestProvider with sub requests<commit_after><?php

namespace AdrienBrault\StatsDCollector\Provider;

use AdrienBrault\StatsDCollector\ParameterProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class SymfonyRequestProvider implements ParameterProviderInterface
{
    /**
     * @var Request|null
     */
    private $request;

    public function __construct(Request $request = null)
    {
        $this->request = $request;
    }

    public function setRequest(Request $request)
    {
        $this->request = $request;
    }

    public function onKernelRequest(GetResponseEvent $event)
    {
        if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
            return;
        }

        $this->setRequest($event->getRequest());
    }

    /**
     * {@inheritdoc}
     */
    public function getParameters()
    {
        $method = null;
        $format = null;
        $scheme = null;
        $ajax = null;
        $locale = null;
        $route = null;

        if (null !== $this->request) {
            $method = strtolower($this->request->getMethod());
            $format = $this->request->getRequestFormat();
            $scheme = $this->request->getScheme();
            $ajax = $this->request->isXmlHttpRequest() ? 'ajax' : 'not_ajax';
            $locale = $this->request->getLocale();
            $route = $this->request->attributes->get('_route');
        }

{'fraction_non_alphanumeric': 0.138550135501355, 'fraction_numerical': 0.0, 'mean_word_length': 2.5793939393939396, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 46, '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': '5137046', 'n_tokens_mistral': 835, 'n_tokens_neox': 821, 'n_words': 152}