Completed
Push — master ( ea0a23...156714 )
by Joachim
12s queued 11s
created

BrandRepository::findByPhrase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBrandPlugin\Doctrine\ORM;
6
7
use Doctrine\ORM\QueryBuilder;
8
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
9
10
class BrandRepository extends EntityRepository implements BrandRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function createListQueryBuilder(): QueryBuilder
16
    {
17
        return $this->createQueryBuilder('o');
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function findByPhrase(string $phrase): array
24
    {
25
        return $this->createQueryBuilder('o')
26
            ->andWhere('o.name LIKE :phrase OR o.code LIKE :phrase')
27
            ->setParameter('phrase', '%' . $phrase . '%')
28
            ->getQuery()
29
            ->getResult()
30
            ;
31
    }
32
}
33