Passed
Pull Request — master (#35)
by Igor
03:31
created

BrandImageRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createPaginatorForBrandAndType() 0 12 1
A createPaginatorForBrand() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBrandPlugin\Doctrine\ORM;
6
7
use Loevgaard\SyliusBrandPlugin\Entity\BrandInterface;
8
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
9
10
class BrandImageRepository extends EntityRepository implements BrandImageRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function createPaginatorForBrand(BrandInterface $brand): iterable
16
    {
17
        $queryBuilder = $this->createQueryBuilder('o')
18
            ->andWhere('o.owner = :brand')
19
            ->setParameter('brand', $brand)
20
        ;
21
22
        return $this->getPaginator($queryBuilder);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function createPaginatorForBrandAndType(BrandInterface $brand, string $type): iterable
29
    {
30
        $queryBuilder = $this->createQueryBuilder('o')
31
32
            ->andWhere('o.type = :type')
33
            ->setParameter('type', $type)
34
35
            ->andWhere('o.owner = :brand')
36
            ->setParameter('brand', $brand)
37
        ;
38
39
        return $this->getPaginator($queryBuilder);
40
    }
41
}
42