<commit_before><?php

namespace LizardsAndPumpkins\DataPool\KeyValue\Credis;

use LizardsAndPumpkins\DataPool\KeyValue\Exception\KeyNotFoundException;
use LizardsAndPumpkins\DataPool\KeyValue\KeyValueStore;
use Credis_Client;

class CredisKeyValueStore implements KeyValueStore
{
    /**
     * @var Credis_Client
     */
    private $client;

    public function __construct(Credis_Client $client)
    {
        $this->client = $client;
    }

    /**
     * @param string $key
     * @return bool|string
     */
    public function get($key)
    {
        if (!$value = $this->client->get($key)) {
            throw new KeyNotFoundException(sprintf('Key not found "%s"', $key));
        }

        return $value;
    }

    /**
     * @param string $key
     * @param mixed $value
     */
    public function set($key, $value)
    {
        $this->client->set($key, $value);
    }

    /**
     * @param string $key
     * @return bool
     */
    public function has($key)
    {
        return (bool) $this->client->exists($key);
    }

    /**
     * @param string[] $keys
     * @return mixed[]
     */
    public function multiGet(array $keys)
    {
        if (count($keys) === 0) {
            return [];
        }

        $values = $this->client->mGet($keys);
        $items = array_combine($keys, $values);

        return array_filter($items);
    }

    /**
     * @param mixed[] $items
     */<commit_msg>Issue #10: Make array types-hints more exact<commit_after><?php

namespace LizardsAndPumpkins\DataPool\KeyValue\Credis;

use LizardsAndPumpkins\DataPool\KeyValue\Exception\KeyNotFoundException;
use LizardsAndPumpkins\DataPool\KeyValue\KeyValueStore;
use Credis_Client;

class CredisKeyValueStore implements KeyValueStore
{
    /**
     * @var Credis_Client
     */
    private $client;

    public function __construct(Credis_Client $client)
    {
        $this->client = $client;
    }

    /**
     * @param string $key
     * @return bool|string
     */
    public function get($key)
    {
        if (!$value = $this->client->get($key)) {
            throw new KeyNotFoundException(sprintf('Key not found "%s"', $key));
        }

        return $value;
    }

    /**
     * @param string $key
     * @param string $value
     */
    public function set($key, $value)
    {
        $this->client->set($key, $value);
    }

    /**
     * @param string $key
     * @return bool
     */
    public function has($key)
    {
        return (bool) $this->client->exists($key);
    }

    /**
     * @param string[] $keys
     * @return string[]
     */
    public function multiGet(array $keys)
    {
        if (count($keys) === 0) {
            return [];
        }

        $values = $this->client->mGet($keys);
        $items = array_combine($keys, $values);

        return array_filter($items);
    }

    /**
     * @param string[] $items
     */
{'fraction_non_alphanumeric': 0.14380222841225626, 'fraction_numerical': 0.001392757660167131, 'mean_word_length': 2.13646288209607, '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': '2105304', 'n_tokens_mistral': 912, 'n_tokens_neox': 889, 'n_words': 184}