<commit_before><?php

namespace Vision\Hydrator\Strategy;

use Vision\Annotation\Paragraph;
use Vision\Annotation\Symbol;
use Vision\Annotation\Word;
use Zend\Hydrator\Strategy\StrategyInterface;

class SymbolsStrategy implements StrategyInterface
{
    /**
     * @var TextPropertyStrategy
     */
    protected $textPropertyStrategy;

    /**
     * @var BoundingPolyStrategy
     */
    protected $boundingPolyStrategy;

    public function __construct()
    {
        $this->textPropertyStrategy = new TextPropertyStrategy;
        $this->boundingPolyStrategy = new BoundingPolyStrategy;
    }

    /**
     * @param Symbol[] $value
     * @return array
     */
    public function extract($value)
    {
        return array_map(function(Symbol $symbolEntity) {
            return array_filter([
                'property' => $this->textPropertyStrategy->extract($symbolEntity->getProperty()),
                'boundingBox' => $this->boundingPolyStrategy->extract($symbolEntity->getBoundingBox()),
                'text' => $symbolEntity->getSymbols(),
            ]);
        }, $value);
    }

    /**
     * @param array $value
     * @return Symbol[]
     */
    public function hydrate($value)
    {
        $symbolEntities = [];

        foreach ($value as $symbolEntityInfo) {
            $symbolEntities[] = new Symbol(
                $this->textPropertyStrategy->hydrate($symbolEntityInfo['property']),
                $this->boundingPolyStrategy->hydrate($symbolEntityInfo['boundingBox']),
                $symbolEntityInfo['text']<commit_msg>Fix issue detected by scrutinizer<commit_after><?php

namespace Vision\Hydrator\Strategy;

use Vision\Annotation\Paragraph;
use Vision\Annotation\Symbol;
use Vision\Annotation\Word;
use Zend\Hydrator\Strategy\StrategyInterface;

class SymbolsStrategy implements StrategyInterface
{
    /**
     * @var TextPropertyStrategy
     */
    protected $textPropertyStrategy;

    /**
     * @var BoundingPolyStrategy
     */
    protected $boundingPolyStrategy;

    public function __construct()
    {
        $this->textPropertyStrategy = new TextPropertyStrategy;
        $this->boundingPolyStrategy = new BoundingPolyStrategy;
    }

    /**
     * @param Symbol[] $value
     * @return array
     */
    public function extract($value)
    {
        return array_map(function(Symbol $symbolEntity) {
            return array_filter([
                'property' => $this->textPropertyStrategy->extract($symbolEntity->getProperty()),
                'boundingBox' => $this->boundingPolyStrategy->extract($symbolEntity->getBoundingBox()),
                'text' => $symbolEntity->getText(),
            ]);
        }, $value);
    }

    /**
     * @param array $value
     * @return Symbol[]
     */
    public function hydrate($value)
    {
        $symbolEntities = [];

        foreach ($value as $symbolEntityInfo) {
            $symbolEntities[] = new Symbol(
                $this->textPropertyStrategy->hydrate($symbolEntityInfo['property']),
                $this->boundingPolyStrategy->hydrate($symbolEntityInfo['boundingBox']),
                $symbolEntityInfo['text']
{'fraction_non_alphanumeric': 0.12256623045004787, 'fraction_numerical': 0.0, 'mean_word_length': 2.6399535423925666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '1874531', 'n_tokens_mistral': 835, 'n_tokens_neox': 805, 'n_words': 145}