<commit_before><?php

/*
 * This file is part of Transfer.
 *
 * For the full copyright and license information, please view the LICENSE file located
 * in the root directory.
 */

namespace Transfer\Storage;

use Transfer\Storage\Exception\ObjectNotFoundException;

/**
 * In-memory storage.
 */
class InMemoryStorage extends AbstractStorage
{
    /**
     * @var array
     */
    private $data = array();

    /**
     * {@inheritdoc}
     */
    public function add($object, $id = null)
    {
        if ($id == null) {
            $id = $this->hashingStrategy->hash($object);
        }

        $this->data[$id] = $object;

        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function contains($object)
    {
        return $this->containsId($this->hashingStrategy->hash($object));
    }

    /**
     * {@inheritdoc}
     */
    public function containsId($id)
    {
        return array_key_exists($id, $this->data);
    }

    /**
     * {@inheritdoc}
     */
    public function findById($id)
    {
        if (!$this->containsId($id)) {<commit_msg>#3 Fix id type ambiguity<commit_after><?php

/*
 * This file is part of Transfer.
 *
 * For the full copyright and license information, please view the LICENSE file located
 * in the root directory.
 */

namespace Transfer\Storage;

use Transfer\Storage\Exception\ObjectNotFoundException;

/**
 * In-memory storage.
 */
class InMemoryStorage extends AbstractStorage
{
    /**
     * @var array
     */
    private $data = array();

    /**
     * {@inheritdoc}
     */
    public function add($object, $id = null)
    {
        if ($id === null) {
            $id = $this->hashingStrategy->hash($object);
        }

        $this->data[$id] = $object;

        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function contains($object)
    {
        return $this->containsId($this->hashingStrategy->hash($object));
    }

    /**
     * {@inheritdoc}
     */
    public function containsId($id)
    {
        return array_key_exists($id, $this->data);
    }

    /**
     * {@inheritdoc}
     */
    public function findById($id)
    {
        if (!$this->containsId($id)) {
{'fraction_non_alphanumeric': 0.1488970588235294, 'fraction_numerical': 0.00045955882352941176, 'mean_word_length': 2.1323741007194243, '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': '2544793', 'n_tokens_mistral': 649, 'n_tokens_neox': 639, 'n_words': 150}