<commit_before><?php namespace Pantono\Core\Entity\Hydrator;

use Doctrine\ORM\EntityManager;
use ReflectionObject;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Util\Inflector;

class EntityHydrator
{
    private $entityManager;
    private $currentEntity;
    /**
     * @var \Doctrine\ORM\Mapping\ClassMetadata
     */
    private $currentMetaData;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function hydrate($entityClass, $data)
    {
        $this->currentMetaData = $this->entityManager->getClassMetadata($entityClass);
        $this->currentEntity = new $entityClass;
        $reflectionClass = new \ReflectionClass($entityClass);
        foreach ($reflectionClass->getProperties() as $property) {
            $properties[$property->getName()] = true;
        }
        foreach ($data as $key => $value) {
            if (isset($properties[$key]) && $value !== null) {
                $setter = sprintf('set%s', ucfirst(Inflector::camelize($key)));
                $value = $this->mapField($key, $value);
                if ($value) {
                    $this->currentEntity->{$setter}($value);
                }
            }
        }
        return $this->currentEntity;
    }
<commit_msg>Adding in missing property initialisation<commit_after><?php namespace Pantono\Core\Entity\Hydrator;

use Doctrine\ORM\EntityManager;
use ReflectionObject;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Util\Inflector;

class EntityHydrator
{
    private $entityManager;
    private $currentEntity;
    /**
     * @var \Doctrine\ORM\Mapping\ClassMetadata
     */
    private $currentMetaData;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function hydrate($entityClass, $data)
    {
        $this->currentMetaData = $this->entityManager->getClassMetadata($entityClass);
        $this->currentEntity = new $entityClass;
        $reflectionClass = new \ReflectionClass($entityClass);
        $properties = [];
        foreach ($reflectionClass->getProperties() as $property) {
            $properties[$property->getName()] = true;
        }
        foreach ($data as $key => $value) {
            if (isset($properties[$key]) && $value !== null) {
                $setter = sprintf('set%s', ucfirst(Inflector::camelize($key)));
                $value = $this->mapField($key, $value);
                if ($value) {
                    $this->currentEntity->{$setter}($value);
                }
            }
        }
        return $this->currentEntity;
    }

{'fraction_non_alphanumeric': 0.13301043219076006, 'fraction_numerical': 0.0, 'mean_word_length': 2.589572192513369, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '930105', 'n_tokens_mistral': 741, 'n_tokens_neox': 735, 'n_words': 135}