<commit_before><?php
/**
 * Enter description here...
 *
 * @category
 * @package
 * @author     <NAME> <<EMAIL>>
 */

namespace KlarnaKco\Traits;

use ArrayIterator;
use KlarnaKco\ShippingOption;

trait Collection
{
    /**
     * @var array
     */
    protected $items = [];

    /**
     * @param ShippingOption $item
     *
     * @return $this
     */
    public function addItem(ShippingOption $item)
    {
        $this->items[] = $item;

        return $this;
    }

    /**
     * @return array
     */
    public function getItems()
    {
        return $this->items;
    }

    /**
     * @return ArrayIterator
     */
    public function getIterator()
    {
        return new ArrayIterator($this->items);
    }

    /**
     * @param mixed $key
     *
     * @return bool
     */
    public function offsetExists($key)
    {
        return array_key_exists($key, $this->items);
    }

    /**
     * @param mixed $key
     *
     * @return mixed
     */
    public function offsetGet($key)
    {
        return $this->items[$key];
    }

    /**
     * @param mixed $key
     * @param mixed $value
     */
    public function offsetSet($key, $value)
    {
        if (is_null($key)) {
            $this->items[] = $value;
        } else {
            $this->items[$key] = $value;
        }
    }

    /**
     * @param mixed $key
     */
    public function offsetUnset($key)
    {
        unset($this->items[$key]);
    }

    /**
     * @return int
     */
    public function count()
    {
        return count($this->items);
    }
}
<commit_msg>Fixed collection trait to accept proper item type<commit_after><?php
/**
 * Enter description here...
 *
 * @category
 * @package
 * @author     <NAME> <<EMAIL>>
 */

namespace KlarnaKco\Traits;

use ArrayIterator;
use KlarnaKco\ModelAbstract;

trait Collection
{
    /**
     * @var array
     */
    protected $items = [];

    /**
     * @param ModelAbstract $item
     *
     * @return $this
     */
    public function addItem(ModelAbstract $item)
    {
        $this->items[] = $item;

        return $this;
    }

    /**
     * @return array
     */
    public function getItems()
    {
        return $this->items;
    }

    /**
     * @return ArrayIterator
     */
    public function getIterator()
    {
        return new ArrayIterator($this->items);
    }

    /**
     * @param mixed $key
     *
     * @return bool
     */
    public function offsetExists($key)
    {
        return array_key_exists($key, $this->items);
    }

    /**
     * @param mixed $key
     *
     * @return mixed
     */
    public function offsetGet($key)
    {
        return $this->items[$key];
    }

    /**
     * @param mixed $key
     * @param mixed $value
     */
    public function offsetSet($key, $value)
    {
        if (is_null($key)) {
            $this->items[] = $value;
        } else {
            $this->items[$key] = $value;
        }
    }

    /**
     * @param mixed $key
     */
    public function offsetUnset($key)
    {
        unset($this->items[$key]);
    }

    /**
     * @return int
     */
    public function count()
    {
        return count($this->items);
    }
}

{'fraction_non_alphanumeric': 0.148781259892371, 'fraction_numerical': 0.0, 'mean_word_length': 1.6245847176079735, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '7525826', 'n_tokens_mistral': 997, 'n_tokens_neox': 983, 'n_words': 209}