<commit_before><?php

/**
 * MemoryHandler.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace Link0\Profiler\PersistenceHandler;

use Link0\Profiler\PersistenceHandler;
use Link0\Profiler\PersistenceHandlerInterface;
use Link0\Profiler\Profile;

/**
 * MemoryHandler implementation for PersistenceHandler's, can be useful in unit tests
 *
 * @package Link0\Profiler\PersistenceHandler
 */
final class MemoryHandler extends PersistenceHandler implements PersistenceHandlerInterface
{
    /**
     * @var array $state
     */
    protected $state = array();

    /**
     * Returns a list of Identifier strings
     * Unfortunately the list() method is reserved
     *
     * @return string[]
     */
    public function getList()
    {
        return array_keys($this->state);
    }

    /**
     * @param  string       $identifier
     * @return Profile|null $profile
     */
    public function retrieve($identifier)
    {
        return isset($this->state[$identifier]) === true ? $this->state[$identifier] : null;
    }

    /**
     * @param  Profile                     $profile
     * @return PersistenceHandlerInterface
     */
    public function persist(Profile $profile)
    {
        $this->state[$profile->getIdentifier()] = $profile;<commit_msg>Docblock to indicate array indices<commit_after><?php

/**
 * MemoryHandler.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace Link0\Profiler\PersistenceHandler;

use Link0\Profiler\PersistenceHandler;
use Link0\Profiler\PersistenceHandlerInterface;
use Link0\Profiler\Profile;

/**
 * MemoryHandler implementation for PersistenceHandler's, can be useful in unit tests
 *
 * @package Link0\Profiler\PersistenceHandler
 */
final class MemoryHandler extends PersistenceHandler implements PersistenceHandlerInterface
{
    /**
     * @var array $state
     */
    protected $state = array();

    /**
     * Returns a list of Identifier strings
     * Unfortunately the list() method is reserved
     *
     * @return array<integer|string>
     */
    public function getList()
    {
        return array_keys($this->state);
    }

    /**
     * @param  string       $identifier
     * @return Profile|null $profile
     */
    public function retrieve($identifier)
    {
        return isset($this->state[$identifier]) === true ? $this->state[$identifier] : null;
    }

    /**
     * @param  Profile                     $profile
     * @return PersistenceHandlerInterface
     */
    public function persist(Profile $profile)
    {
        $this->state[$profile->getIdentifier()] = $profile;
{'fraction_non_alphanumeric': 0.1166535742340927, 'fraction_numerical': 0.003927729772191673, 'mean_word_length': 2.830075187969925, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, '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': '3951935', 'n_tokens_mistral': 690, 'n_tokens_neox': 692, 'n_words': 167}