<commit_before><?php

namespace Happyr\DoctrineSpecification;

use Doctrine\ORM\EntityRepository;

/**
 * Class EntitySpecificationRepository
 *
 * @author <NAME>
 * @author <NAME>
 *
 */
class EntitySpecificationRepository extends EntityRepository
{
    /**
     * Get result when you match with a Specification
     *
     * @param Specification $specification
     *
     * @return mixed
     * @throws \InvalidArgumentException
     */
    public function match(Specification $specification)
    {
        //check if the Specification is supported
        if (!$specification->supports($this->getEntityName())) {
            throw new \InvalidArgumentException("Specification not supported by this repository.");
        }

        //get the Query Builder
        $qb = $this->createQueryBuilder('e');

        //match with the Specification
        $expr = $specification->match($qb, 'e');

        //add teh result expression in the where clause
        $query = $qb->where($expr)->getQuery();

        //give the Specification a change to modify the query
        $specification->modifyQuery($query);

        //get and return the result
        return $query->getResult();
    }
}<commit_msg>Pass hydration mode to getResult method (#44).<commit_after><?php

namespace Happyr\DoctrineSpecification;

use Doctrine\ORM\EntityRepository;

/**
 * Class EntitySpecificationRepository
 *
 * @author <NAME>
 * @author <NAME>
 *
 */
class EntitySpecificationRepository extends EntityRepository
{
    /**
     * Get result when you match with a Specification
     *
     * @param Specification $specification
     *
     * @return mixed
     * @throws \InvalidArgumentException
     */
    public function match(Specification $specification)
    {
        //check if the Specification is supported
        if (!$specification->supports($this->getEntityName())) {
            throw new \InvalidArgumentException("Specification not supported by this repository.");
        }

        //get the Query Builder
        $qb = $this->createQueryBuilder('e');

        //match with the Specification
        $expr = $specification->match($qb, 'e');

        //add teh result expression in the where clause
        $query = $qb->where($expr)->getQuery();

        //give the Specification a change to modify the query
        $specification->modifyQuery($query);

        //get and return the result
        return $query->getResult($query->getHydrationMode());
    }
}
{'fraction_non_alphanumeric': 0.11020740138267589, 'fraction_numerical': 0.0008133387555917039, 'mean_word_length': 2.7442922374429224, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '138759', 'n_tokens_mistral': 646, 'n_tokens_neox': 626, 'n_words': 186}