Completed
Push — master ( 016326...2f159d )
by Joachim
04:38
created

BrandRepository::findOneBySlug()   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 9.4285
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
     * @return BrandInterface|null
15
     * @throws \Doctrine\ORM\NonUniqueResultException
16
     */
17
    public function findOneBySlug(string $slug): ?BrandInterface
18
    {
19
        return $this->createQueryBuilder('o')
20
            ->where('o.slug = :slug')
21
            ->setParameter('slug', $slug)
22
            ->getQuery()
23
            ->getOneOrNullResult()
24
        ;
25
    }
26
}