<commit_before><?php

namespace Kunstmaan\FixturesBundle\Populator;


use Doctrine\Common\Collections\ArrayCollection;
use Kunstmaan\FixturesBundle\Populator\Methods\MethodInterface;

class Populator
{
    /**
     * @var MethodInterface[]
     */
    private $populators;

    public function __construct()
    {
        $this->populators = new ArrayCollection();
    }

    public function populate($entity, $data)
    {
        foreach ($data as $property => $value) {
            foreach ($this->populators as $populator) {
                if ($populator->canSet($entity, $property, $value)) {
                    if ($value instanceof \Kunstmaan\FixturesBundle\Loader\Fixture) {
                        $populator->set($entity, $property, $value->getEntity());
                    } else {
                        $populator->set($entity, $property, $value);
                    }
                    break;
                }
            }
        }
    }
<commit_msg>Fix for fixtures populator entity array<commit_after><?php

namespace Kunstmaan\FixturesBundle\Populator;


use Doctrine\Common\Collections\ArrayCollection;
use Kunstmaan\FixturesBundle\Populator\Methods\MethodInterface;

class Populator
{
    /**
     * @var MethodInterface[]
     */
    private $populators;

    public function __construct()
    {
        $this->populators = new ArrayCollection();
    }

    public function populate($entity, $data)
    {
        foreach ($data as $property => $value) {
            foreach ($this->populators as $populator) {
                if ($populator->canSet($entity, $property, $value)) {
                    if ($value instanceof \Kunstmaan\FixturesBundle\Loader\Fixture) {
                        $populator->set($entity, $property, $value->getEntity());
                    } elseif(is_array($value)) {
                        foreach($value as &$item) {
                            if($item instanceof \Kunstmaan\FixturesBundle\Loader\Fixture) {
                                $item = $item->getEntity();
                            }
                        }
                        $populator->set($entity, $property, $value);
                    } else {
                        $populator->set($entity, $property, $value);
                    }
                    break;
                }
            }
        }
    }

{'fraction_non_alphanumeric': 0.11659574468085106, 'fraction_numerical': 0.0, 'mean_word_length': 1.609322974472808, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '4702869', 'n_tokens_mistral': 622, 'n_tokens_neox': 594, 'n_words': 113}