<commit_before><?php

namespace Furniture\RetailerBundle\Entity\Repository;

use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;

class RetailerProfileRepository extends EntityRepository
{
    /**
     * Create filter paginator
     *
     * @param array $criteria
     *
     * @return Pagerfanta
     */
    public function createFilterPaginator($criteria = [])
    {
        $qb = $this->createQueryBuilder('rp');

        if (!empty($criteria['name'])) {
            $qb
                ->andWhere('rp.name LIKE :name')
                ->setParameter('name', '%' . $criteria['name'] . '%');<commit_msg>#60 Fix repository for search retailer profile by name<commit_after><?php

namespace Furniture\RetailerBundle\Entity\Repository;

use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;

class RetailerProfileRepository extends EntityRepository
{
    /**
     * Create filter paginator
     *
     * @param array $criteria
     *
     * @return Pagerfanta
     */
    public function createFilterPaginator($criteria = [])
    {
        $qb = $this->createQueryBuilder('rp');

        if (!empty($criteria['name'])) {
            $words= explode(' ', $criteria['name']);
            $words = array_map('trim', $words);

            $orX = $qb->expr()->orX();

            foreach ($words as $index => $word) {
                $key = sprintf(':name_word_%d', $index);
                $orX->add('LOWER(rp.name) LIKE ' . $key);
                $qb->setParameter($key, '%' . mb_strtolower($word) . '%');
            }

            $qb
                ->andWhere($orX);
{'fraction_non_alphanumeric': 0.14351851851851852, 'fraction_numerical': 0.0011574074074074073, 'mean_word_length': 2.572314049586777, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2373118', 'n_tokens_mistral': 534, 'n_tokens_neox': 519, 'n_words': 93}