<commit_before><?php

namespace Brera\Product\Block;

use Brera\Product\FilterNavigationFilterCollection;
use Brera\Renderer\Block;
use Brera\Renderer\InvalidDataObjectException;

class FilterNavigationBlock extends Block
{
    const VALUES_SEPARATOR = ',';

    /**
     * @var array[]
     */
    private $lazyLoadedSelectedFilters;

    /**
     * @return FilterNavigationFilterCollection
     */
    public function getFilterCollection()
    {
        $this->validateDataObject();
        return $this->getDataObject();
    }

    private function validateDataObject()
    {
        $dataObject = $this->getDataObject();
        if (!($dataObject instanceof FilterNavigationFilterCollection)) {
            throw new InvalidDataObjectException(
                sprintf(
                    'Data object must be instance of %s, got "%s".',
                    FilterNavigationFilterCollection::class,
                    $this->getVariableType($dataObject)
                )
            );
        }
    }

    /**
     * @param mixed $variable
     * @return string
     */
    private function getVariableType($variable)
    {
        return 'object' !== gettype($variable) ? gettype($variable) : get_class($variable);
    }

    /**
     * @param string $filterCode<commit_msg>Issue #230: Format ternary operator<commit_after><?php

namespace Brera\Product\Block;

use Brera\Product\FilterNavigationFilterCollection;
use Brera\Renderer\Block;
use Brera\Renderer\InvalidDataObjectException;

class FilterNavigationBlock extends Block
{
    const VALUES_SEPARATOR = ',';

    /**
     * @var array[]
     */
    private $lazyLoadedSelectedFilters;

    /**
     * @return FilterNavigationFilterCollection
     */
    public function getFilterCollection()
    {
        $this->validateDataObject();
        return $this->getDataObject();
    }

    private function validateDataObject()
    {
        $dataObject = $this->getDataObject();
        if (!($dataObject instanceof FilterNavigationFilterCollection)) {
            throw new InvalidDataObjectException(
                sprintf(
                    'Data object must be instance of %s, got "%s".',
                    FilterNavigationFilterCollection::class,
                    $this->getVariableType($dataObject)
                )
            );
        }
    }

    /**
     * @param mixed $variable
     * @return string
     */
    private function getVariableType($variable)
    {
        return 'object' !== gettype($variable) ?
            gettype($variable) :
            get_class($variable);
    }

    /**
     * @param string $filterCode
{'fraction_non_alphanumeric': 0.10643185298621746, 'fraction_numerical': 0.0011485451761102604, 'mean_word_length': 2.2540473225404734, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2640041', 'n_tokens_mistral': 672, 'n_tokens_neox': 657, 'n_words': 137}