<commit_before><?php

namespace Dark\RedisListBundle\Manager;

use Predis\Client;

class Manager
{
    /**
     * @var \Predis\Client
     */
    private $client;

    public function __construct(Client $client)
    {
        $this->client = $client;
    }
    
    public function pull($entities)
    {
        $entities = $this->prepareEntities($entities);
        
        foreach ($entities as $entity) {
            if (!method_exists($entity, 'setRedisFields')) {
                throw new ManagerException(sprintf("Entity %s must have setRedisFields() method.", get_class($entity)));
            }
            
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());

            $fields = array_keys($entity->getRedisFields());
            $fields = $this->client->hmget($hashName, $fields);

            $entity->setRedisFields($fields);
        }
    }
    
    public function save($entities)
    {
        $entities = $this->prepareEntities($entities);
        
        foreach ($entities as $entity) {
            if (!method_exists($entity, 'getRedisFields')) {
                throw new ManagerException(sprintf("Entity %s must have getRedisFields() method.", get_class($entity)));
            }
            
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());
            $fields = $entity->getRedisFields();

            $this->client->hmset($hashName, $fields);
        }
    }

    public function remove($entities)
    {
        $entities = $this->prepareEntities($entities);

        foreach ($entities as $entity) {
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());
            $this->client->del($hashName);
        }
    }<commit_msg>hmget doesnt provide fields in array keys<commit_after><?php

namespace Dark\RedisListBundle\Manager;

use Predis\Client;

class Manager
{
    /**
     * @var \Predis\Client
     */
    private $client;

    public function __construct(Client $client)
    {
        $this->client = $client;
    }
    
    public function pull($entities)
    {
        $entities = $this->prepareEntities($entities);
        
        foreach ($entities as $entity) {
            if (!method_exists($entity, 'setRedisFields')) {
                throw new ManagerException(sprintf("Entity %s must have setRedisFields() method.", get_class($entity)));
            }
            
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());

            $fields = array_combine(
                array_keys($entity->getRedisFields()),
                $this->client->hmget($hashName, array_keys($entity->getRedisFields())
            ));

            $entity->setRedisFields($fields);
        }
    }
    
    public function save($entities)
    {
        $entities = $this->prepareEntities($entities);
        
        foreach ($entities as $entity) {
            if (!method_exists($entity, 'getRedisFields')) {
                throw new ManagerException(sprintf("Entity %s must have getRedisFields() method.", get_class($entity)));
            }
            
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());
            $fields = $entity->getRedisFields();

            $this->client->hmset($hashName, $fields);
        }
    }

    public function remove($entities)
    {
        $entities = $this->prepareEntities($entities);

        foreach ($entities as $entity) {
            $hashName = sprintf("%s:%d", end((explode("\\", get_class($entity)))), $entity->getId());
            $this->client->del($hashName);
        }
    }
{'fraction_non_alphanumeric': 0.16122944189808575, 'fraction_numerical': 0.0, 'mean_word_length': 2.237347294938918, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '1413468', 'n_tokens_mistral': 1024, 'n_tokens_neox': 1053, 'n_words': 194}