<commit_before><?php
/**
 * Abstract implementation of a Collection
 *
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
 * @copyright   Copyright (c) 2016 <NAME> <<EMAIL>>
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
 * @category    PHPExif
 * @package     Common
 * @codeCoverageIgnore
 */

namespace PHPExif\Common\Collection;

use PHPExif\Common\Exception\Collection\ElementAlreadyExistsException;
use PHPExif\Common\Exception\Collection\ElementNotExistsException;

/**
 * AbstractCollection class
 *
 * @category    PHPExif
 * @package     Common
 */
abstract class AbstractCollection implements Collection
{
    /**
     * Holds the entries of the collection
     *
     * @var array
     */
    private $elements;

    /**
     * Collection constructor
     *
     * @param array $data
     */
    public function __construct(array $elements = array())
    {
        $this->elements = array();

        foreach ($elements as $name => $config) {
            $this->add($name, $config);
        }
    }

    /**
     * {@inheritDoc}
     */
    public function add($key, $value)
    {
        if ($this->exists($key)) {
            throw ElementAlreadyExistsException::withKey($key);
        }

        $this->elements[$key] = $value;

        return $this;
    }

    /**
     * {@inheritDoc}
     */
    public function exists($key)
    {
        return array_key_exists($key, $this->elements);
    }

    /**
     * {@inheritDoc}
     */
    public function get($key)
    {
        if (!$this->exists($key)) {
            throw ElementNotExistsException::withKey($key);
        }

        return $this->element[$key];
    }
}<commit_msg>Bugfix: AbstractCollection::exists() checked wrong property<commit_after><?php
/**
 * Abstract implementation of a Collection
 *
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
 * @copyright   Copyright (c) 2016 <NAME> <<EMAIL>>
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
 * @category    PHPExif
 * @package     Common
 * @codeCoverageIgnore
 */

namespace PHPExif\Common\Collection;

use PHPExif\Common\Exception\Collection\ElementAlreadyExistsException;
use PHPExif\Common\Exception\Collection\ElementNotExistsException;

/**
 * AbstractCollection class
 *
 * @category    PHPExif
 * @package     Common
 */
abstract class AbstractCollection implements Collection
{
    /**
     * Holds the entries of the collection
     *
     * @var array
     */
    private $elements;

    /**
     * Collection constructor
     *
     * @param array $data
     */
    public function __construct(array $elements = array())
    {
        $this->elements = array();

        foreach ($elements as $name => $config) {
            $this->add($name, $config);
        }
    }

    /**
     * {@inheritDoc}
     */
    public function add($key, $value)
    {
        if ($this->exists($key)) {
            throw ElementAlreadyExistsException::withKey($key);
        }

        $this->elements[$key] = $value;

        return $this;
    }

    /**
     * {@inheritDoc}
     */
    public function exists($key)
    {
        return array_key_exists($key, $this->elements);
    }

    /**
     * {@inheritDoc}
     */
    public function get($key)
    {
        if (!$this->exists($key)) {
            throw ElementNotExistsException::withKey($key);
        }

        return $this->elements[$key];
    }
}
{'fraction_non_alphanumeric': 0.13456614509246087, 'fraction_numerical': 0.002275960170697013, 'mean_word_length': 2.339031339031339, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '3296223', 'n_tokens_mistral': 1022, 'n_tokens_neox': 993, 'n_words': 212}