<commit_before><?php
namespace Yjv\Bundle\ReportRenderingBundle\Filter\Loader;

use Yjv\ReportRendering\Filter\MultiReportFilterCollectionInterface;

use Yjv\ReportRendering\FilterConstants;

use Symfony\Component\HttpFoundation\Request;

use Yjv\ReportRendering\Filter\FilterCollectionInterface;

class ParameterBagLoader implements LoaderInterface
{
    protected $attributeName;
    protected $path;
    
    public function __construct($attributeName = 'request', $path = 'report_filters')
    {
        $this->attributeName = $attributeName;
        $this->path = $path;
    }
    
    public function load(FilterCollectionInterface $filters, Request $request)
    {
        $filterData = $request->{$this->attributeName}->get($this->path, array());
        $filterData = $this->normalizeFilterData($filterData, $filters);
        
        foreach ($filterData as $reportId => $filterValues) {
            
            if ($filters instanceof MultiReportFilterCollectionInterface) {
                
                $filters->setReportId($reportId);
            }
            
            $filters->setAll($filterValues);
        }
    }
    
    protected function normalizeFilterData(array $filterData, FilterCollectionInterface $filters)
    {
        if (!$filters instanceof MultiReportFilterCollectionInterface) {
            
            $filterData = array('report_id' => $filterData);
        }
        
        return array_map(function($data) 
        {
            foreach ($data as $key => $value) {
                
                if ($key == FilterConstants::LIMIT || $key == FilterConstants::OFFSET) {
                    
                    $data[$key] = (int)$value;
                }
                
                if ($key == FilterConstants::SORT) {
                    
                    $data[$key] = (array)$value;
                }
            }
        }, $filterData);
    }
}<commit_msg>fixed the normalization method so it works<commit_after><?php
namespace Yjv\Bundle\ReportRenderingBundle\Filter\Loader;

use Yjv\ReportRendering\Filter\MultiReportFilterCollectionInterface;

use Yjv\ReportRendering\FilterConstants;

use Symfony\Component\HttpFoundation\Request;

use Yjv\ReportRendering\Filter\FilterCollectionInterface;

class ParameterBagLoader implements LoaderInterface
{
    protected $attributeName;
    protected $path;
    
    public function __construct($attributeName = 'request', $path = 'report_filters')
    {
        $this->attributeName = $attributeName;
        $this->path = $path;
    }
    
    public function load(FilterCollectionInterface $filters, Request $request)
    {
        $filterData = $request->{$this->attributeName}->get($this->path, array());
        $filterData = $this->normalizeFilterData($filterData, $filters);

        foreach ($filterData as $reportId => $filterValues) {
            
            if ($filters instanceof MultiReportFilterCollectionInterface) {
                
                $filters->setReportId($reportId);
            }
            
            $filters->setAll($filterValues);
        }
    }
    
    protected function normalizeFilterData(array $filterData, FilterCollectionInterface $filters)
    {
        if (!$filters instanceof MultiReportFilterCollectionInterface) {
            
            $filterData = array('report_id' => $filterData);
        }

        return array_map(function($data) 
        {
            foreach ($data as $key => $value) {
                
                if ($key == FilterConstants::LIMIT || $key == FilterConstants::OFFSET) {
                    
                    $data[$key] = (int)$value;
                }
                
                if ($key == FilterConstants::SORT) {
                    
                    $data[$key] = (array)$value;
                }
            }
            
            return $data;
        }, $filterData);
    }
}
{'fraction_non_alphanumeric': 0.10706967213114754, 'fraction_numerical': 0.0, 'mean_word_length': 2.003846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '5432491', 'n_tokens_mistral': 978, 'n_tokens_neox': 965, 'n_words': 178}