<commit_before><?php
/**
 * This file is part of the Kappa\Doctrine package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the license.md
 * file that was distributed with this source code.
 */

namespace Kappa\Doctrine\Hydrators;

use Doctrine\ORM\EntityManager;
use Kappa\Doctrine\Helpers\EntityManipulator;
use Kappa\Doctrine\ReflectionException;

/**
 * Class ArrayHydrator
 * @package Kappa\Doctrine\Hydrators
 */
class ArrayHydrator
{
	/** @var \Doctrine\ORM\EntityManager */
	private $entityManager;

	/** @var \Kappa\Doctrine\Helpers\EntityManipulator */
	private $entityManipulator;

	/**
	 * @param EntityManager $entityManager
	 * @param EntityManipulator $entityManipulator
	 */
	public function __construct(EntityManager $entityManager, EntityManipulator $entityManipulator)
	{
		$this->entityManager = $entityManager;
		$this->entityManipulator = $entityManipulator;
	}

	/**
	 * @param array $array
	 * @param object $entity
	 * @param array $ignore
	 */
	public function hydrate(array &$array, $entity, array $ignore = array())
	{
		$properties = $this->getEntityProperties($entity);
		foreach ($properties as $column) {
			if (!in_array($column, $ignore)) {
				try {
					$array[$column] = $this->entityManipulator->getValue($entity, $column);
				} catch (ReflectionException $e) {
					continue;
				}
			}
		}
	}

	/**
	 * @param object $entity
	 * @return array
	 */
	private function getEntityProperties($entity)
	{
		$entityName = get_class($entity);
		$associationMappings = $this->entityManager->getClassMetadata($entityName)->getAssociationNames();
		$columnNames = $this->entityManager->getClassMetadata($entityName)->getColumnNames();

		return array_merge($columnNames, $associationMappings);
	}
}<commit_msg>Fixed bug with different column and property names<commit_after><?php
/**
 * This file is part of the Kappa\Doctrine package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the license.md
 * file that was distributed with this source code.
 */

namespace Kappa\Doctrine\Hydrators;

use Doctrine\ORM\EntityManager;
use Kappa\Doctrine\Helpers\EntityManipulator;
use Kappa\Doctrine\ReflectionException;

/**
 * Class ArrayHydrator
 * @package Kappa\Doctrine\Hydrators
 */
class ArrayHydrator
{
	/** @var \Doctrine\ORM\EntityManager */
	private $entityManager;

	/** @var \Kappa\Doctrine\Helpers\EntityManipulator */
	private $entityManipulator;

	/**
	 * @param EntityManager $entityManager
	 * @param EntityManipulator $entityManipulator
	 */
	public function __construct(EntityManager $entityManager, EntityManipulator $entityManipulator)
	{
		$this->entityManager = $entityManager;
		$this->entityManipulator = $entityManipulator;
	}

	/**
	 * @param array $array
	 * @param object $entity
	 * @param array $ignore
	 */
	public function hydrate(array &$array, $entity, array $ignore = array())
	{
		$properties = $this->getEntityProperties($entity);
		foreach ($properties as $column) {
			if (!in_array($column, $ignore)) {
				try {
					$array[$column] = $this->entityManipulator->getValue($entity, $column);
				} catch (ReflectionException $e) {
					continue;
				}
			}
		}
	}

	/**
	 * @param object $entity
	 * @return array
	 */
	private function getEntityProperties($entity)
	{
		$entityName = get_class($entity);
		$associationMappings = $this->entityManager->getClassMetadata($entityName)->getAssociationNames();
		$columnNames = $this->entityManager->getClassMetadata($entityName)->getFieldNames();

		return array_merge($columnNames, $associationMappings);
	}
}
{'fraction_non_alphanumeric': 0.13303769401330376, 'fraction_numerical': 0.0, 'mean_word_length': 4.586687306501548, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '2971517', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1090, 'n_words': 247}