Passed
Push — master ( af7c17...12d887 )
by Joachim
05:05
created

BrandRepository::findByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\SyliusBrandPlugin\Repository;
6
7
use Loevgaard\SyliusBrandPlugin\Entity\BrandInterface;
8
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
9
10
class BrandRepository extends EntityRepository implements BrandRepositoryInterface
11
{
12
    /**
13
     * @param string $slug
14
     *
15
     * @return BrandInterface|null
16
     *
17
     * @throws \Doctrine\ORM\NonUniqueResultException
18
     */
19
    public function findOneBySlug(string $slug): ?BrandInterface
20
    {
21
        return $this->createQueryBuilder('o')
22
            ->where('o.slug = :slug')
23
            ->setParameter('slug', $slug)
24
            ->getQuery()
25
            ->getOneOrNullResult()
26
        ;
27
    }
28
29
    public function findByName(string $name): array
30
    {
31
        return $this->findBy([
32
            'name' => $name,
33
        ]);
34
    }
35
}
36