<commit_before><?php

namespace Atrapalo\PHPTools\Collection;

/**
 * Class EntityCollection
 * @package Atrapalo\PHPTools\Collection
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class EntityCollection implements \Countable, \Iterator
{
    /** @var array */
    private $entities;
    /** @var bool */
    protected $allowEntitiesChildren;

    /**
     * @return string
     */
    abstract public static function entityClass(): string;

    /**
     * Collection constructor.
     * @param array $entities
     * @param bool  $allowEntitiesChildren
     * @throws \Exception
     */
    public function __construct(array $entities, bool $allowEntitiesChildren = false)
    {
        if (empty($entities)) {
            throw static::customEmptyException();
        }

        $this->allowEntitiesChildren = $allowEntitiesChildren;

        foreach ($entities as $key => $entity) {
            $this->set($key, $entity);
        }
    }

    /**
     * @param $entity
     * @throws \Exception<commit_msg>Init collection entities to empty array<commit_after><?php

namespace Atrapalo\PHPTools\Collection;

/**
 * Class EntityCollection
 * @package Atrapalo\PHPTools\Collection
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class EntityCollection implements \Countable, \Iterator
{
    /** @var array */
    private $entities = array();
    /** @var bool */
    protected $allowEntitiesChildren;

    /**
     * @return string
     */
    abstract public static function entityClass(): string;

    /**
     * Collection constructor.
     * @param array $entities
     * @param bool  $allowEntitiesChildren
     * @throws \Exception
     */
    public function __construct(array $entities, bool $allowEntitiesChildren = false)
    {
        if (empty($entities)) {
            throw static::customEmptyException();
        }

        $this->allowEntitiesChildren = $allowEntitiesChildren;

        foreach ($entities as $key => $entity) {
            $this->set($key, $entity);
        }
    }

    /**
     * @param $entity
     * @throws \Exception
{'fraction_non_alphanumeric': 0.12548828125, 'fraction_numerical': 0.0, 'mean_word_length': 2.5449826989619377, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '4608094', 'n_tokens_mistral': 554, 'n_tokens_neox': 561, 'n_words': 137}