<commit_before><?php

namespace MatTheCat\HtmlCompressorBundle\EventListener;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\Process\ProcessBuilder;

class ResponseListener
{
    protected $javaPath;
    protected $htmlCompressorPath;
    protected $htmlCompressorOptions;

    public function __construct($javaPath, $htmlCompressorPath, array $htmlCompressorOptions)
    {
        $this->javaPath = $javaPath;
        $this->htmlCompressorPath = $htmlCompressorPath;
        $this->htmlCompressorOptions = $htmlCompressorOptions;
    }

    public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();

        if (!$event->isMasterRequest() or !in_array($event->getRequest()->getRequestFormat(), array('html', 'xml'))) {
            return;
        }

        $pb = new ProcessBuilder(
            array(
                $this->javaPath,
                '-jar',
                $this->htmlCompressorPath,
            )
        );
        foreach ($this->htmlCompressorOptions as $option => $value) {
            if (!is_null($option)) {
                $pb->add($option);
<commit_msg>Valido que el response sea el estándar de Symfony<commit_after><?php

namespace MatTheCat\HtmlCompressorBundle\EventListener;

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\Process\ProcessBuilder;

class ResponseListener
{
    protected $javaPath;
    protected $htmlCompressorPath;
    protected $htmlCompressorOptions;

    public function __construct($javaPath, $htmlCompressorPath, array $htmlCompressorOptions)
    {
        $this->javaPath = $javaPath;
        $this->htmlCompressorPath = $htmlCompressorPath;
        $this->htmlCompressorOptions = $htmlCompressorOptions;
    }

    public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();

        if (!$event->isMasterRequest()
            or
            !in_array($event->getRequest()->getRequestFormat(), array('html', 'xml'))
            or
            get_class($event->getResponse()) !== 'Symfony\Component\HttpFoundation\Response'
        ) {
            return;
        }

        $pb = new ProcessBuilder(
            array(
                $this->javaPath,
                '-jar',
                $this->htmlCompressorPath,
            )
        );
        foreach ($this->htmlCompressorOptions as $option => $value) {
            if (!is_null($option)) {
                $pb->add($option);

{'fraction_non_alphanumeric': 0.1147280666931322, 'fraction_numerical': 0.0, 'mean_word_length': 2.5795454545454546, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4380148', 'n_tokens_mistral': 697, 'n_tokens_neox': 662, 'n_words': 121}