<commit_before><?php

namespace Collections;

use ArrayAccess;
use ArrayIterator;
use Countable;
use IteratorAggregate;

class Dictionary implements DictionaryInterface
{
    use TypeValidator;

    protected $storage;
    protected $keyType;
    protected $valType;

    /**
     * @param $keyType
     * @param $valType
     * @param array $storage
     * @throws Exceptions\InvalidArgumentException
     */
    public function __construct($keyType, $valType, array $storage = [])
    {
        $this->keyType = $this->determineType($keyType, true);

        $this->valType = $this->determineType($valType);

        foreach ($storage as $key => $val) {
            $this->validateItem($key, $this->keyType);
            $this->validateItem($val, $this->valType);<commit_msg>Initialize Dictionary with an empty storage to avoid PHP warnings when calling ::exists() without any data stored (#44)<commit_after><?php

namespace Collections;

use ArrayAccess;
use ArrayIterator;
use Countable;
use IteratorAggregate;

class Dictionary implements DictionaryInterface
{
    use TypeValidator;

    protected $storage = [];
    protected $keyType;
    protected $valType;

    /**
     * @param $keyType
     * @param $valType
     * @param array $storage
     * @throws Exceptions\InvalidArgumentException
     */
    public function __construct($keyType, $valType, array $storage = [])
    {
        $this->keyType = $this->determineType($keyType, true);

        $this->valType = $this->determineType($valType);

        foreach ($storage as $key => $val) {
            $this->validateItem($key, $this->keyType);
            $this->validateItem($val, $this->valType);
{'fraction_non_alphanumeric': 0.12492492492492492, 'fraction_numerical': 0.0012012012012012011, 'mean_word_length': 3.2938144329896906, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '4509538', 'n_tokens_mistral': 471, 'n_tokens_neox': 462, 'n_words': 120}