<commit_before><?php

namespace Raekke;

use Predis\ClientInterface;

/**
 * @package Raekke
 */
class Connection
{
    protected $client;

    /**
     * @param Client $client
     */
    public function __construct(ClientInterface $client)
    {
        $this->client = $client;
    }

    public function count($set)
    {
        return $this->client->llen($set);
    }

    public function all($set)
    {
        return $this->client->smembers($set);
    }

    public function slice($set, $index = 0, $limit = 20)
    {
        return $this->client->lrange($set, $index, $index + $limit - 1);
    }

    public function pop($set, $interval = 5)
    {
        list(, $message) = $this->client->blpop($set, $interval);

        return $message;
    }

    public function push($set, $member)
    {
        $this->client->rpush($set, $member);
    }

    public function has($set, $member)
    {
        return $this->client->sismember($set, $member);
    }

    public function delete($set)
    {
        $this->client->del($set);
    }

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

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

    /**
     * @return Client
     */
    public function getClient()
    {
        return $this->client;
    }<commit_msg>add info method to normalize redis information<commit_after><?php

namespace Raekke;

use Predis\ClientInterface;

/**
 * @package Raekke
 */
class Connection
{
    protected $client;

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

    public function count($set)
    {
        return $this->client->llen($set);
    }

    public function all($set)
    {
        return $this->client->smembers($set);
    }

    public function slice($set, $index = 0, $limit = 20)
    {
        return $this->client->lrange($set, $index, $index + $limit - 1);
    }

    public function pop($set, $interval = 5)
    {
        list(, $message) = $this->client->blpop($set, $interval);

        return $message;
    }

    public function push($set, $member)
    {
        $this->client->rpush($set, $member);
    }

    public function has($set, $member)
    {
        return $this->client->sismember($set, $member);
    }

    public function delete($set)
    {
        $this->client->del($set);
    }

    public function insert($set, $member)
    {
        $this->client->sadd($set, $member);
    }

    public function remove($set, $member)
    {
        $this->client->srem($set, $member);
    }

    public function info()
    {
        $info = array_change_key_case($this->client->info());

        if (!isset($info['server'])) {
            return $info;
        }

        return new \RecursiveIteratorIterator(new \RecursiveArrayIterator($info));
    }

    public function getClient()
    {
        return $this->client;
    }
{'fraction_non_alphanumeric': 0.15671641791044777, 'fraction_numerical': 0.003244646333549643, 'mean_word_length': 2.162051282051282, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '1972446', 'n_tokens_mistral': 994, 'n_tokens_neox': 956, 'n_words': 206}