<commit_before><?php

namespace Happyr\DoctrineSpecification;

use Happyr\DoctrineSpecification\Specification\Specification;

/**
 * This trait should be used by a class extending \Doctrine\ORM\EntityRepository.
 */
trait EntitySpecificationRepositoryTrait
{
    /**
     * @var string alias
     */
    private $alias = 'e';

    /**
     * Get result when you match with a Specification.
     *
     * @param Specification         $specification
     * @param Result\ResultModifier $modifier
     *
     * @return mixed
     */
    public function match(Specification $specification, Result\ResultModifier $modifier = null)
    {
        $alias = $this->alias;
        $qb = $this->createQueryBuilder($alias);

        $specification->modify($qb, $alias);
        $query = $qb->where($specification->getFilter($qb, $alias))->getQuery();

        if ($modifier !== null) {
            $modifier->modify($query);
        }

        return $query->execute();
    }

    /**
     * @param string $alias
     *
     * @return $this
     */
    public function setAlias($alias)
    {
        $this->alias = $alias;

        return $this;
    }

    /**
     * @return string
     */
    public function getAlias()
    {
        return $this->alias;
    }
}<commit_msg>Added prepare function to return a Query<commit_after><?php

namespace Happyr\DoctrineSpecification;

use Doctrine\ORM\Query;
use Happyr\DoctrineSpecification\Specification\Specification;

/**
 * This trait should be used by a class extending \Doctrine\ORM\EntityRepository.
 */
trait EntitySpecificationRepositoryTrait
{
    /**
     * @var string alias
     */
    private $alias = 'e';

    /**
     * Get result when you match with a Specification.
     *
     * @param Specification         $specification
     * @param Result\ResultModifier $modifier
     *
     * @return mixed
     */
    public function match(Specification $specification, Result\ResultModifier $modifier = null)
    {
        $query = $this->prepare($specification, $modifier);

        return $query->execute();
    }

    /**
     * Prepare a Query with a Specification
     *
     * @param Specification         $specification
     * @param Result\ResultModifier $modifier
     *
     * @return Query
     */
    public function prepare(Specification $specification, Result\ResultModifier $modifier = null)
    {
        $alias = $this->alias;
        $qb = $this->createQueryBuilder($alias);

        $specification->modify($qb, $alias);
        $query = $qb->where($specification->getFilter($qb, $alias))->getQuery();

        if ($modifier !== null) {
            $modifier->modify($query);

            return $query;
        }

        return $query;
    }

    /**
     * @param string $alias
     *
     * @return $this
     */
    public function setAlias($alias)
    {
        $this->alias = $alias;

        return $this;
    }

    /**
     * @return string
     */
    public function getAlias()
    {
        return $this->alias;
    }
}
{'fraction_non_alphanumeric': 0.12625250501002003, 'fraction_numerical': 0.0, 'mean_word_length': 2.2204301075268815, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7139010', 'n_tokens_mistral': 876, 'n_tokens_neox': 863, 'n_words': 196}