ComparerRepository::findByToken()   A
last analyzed

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 Locastic\SyliusComparerPlugin\Repository;
6
7
use Locastic\SyliusComparerPlugin\Entity\ComparerInterface;
8
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
9
use Sylius\Component\Core\Model\ShopUserInterface;
10
11
class ComparerRepository extends EntityRepository implements ComparerRepositoryInterface
12
{
13
    /**
14
     * @throws \Doctrine\ORM\NonUniqueResultException
15
     */
16
    public function findByShopUser(ShopUserInterface $shopUser): ?ComparerInterface
17
    {
18
        return $this->createQueryBuilder('comparer')
19
            ->where('comparer.shopUser = :shopUser')
20
            ->setParameter('shopUser', $shopUser)
21
            ->getQuery()
22
            ->getOneOrNullResult()
23
        ;
24
    }
25
26
    /**
27
     * @throws \Doctrine\ORM\NonUniqueResultException
28
     */
29
    public function findByToken(string $token): ?ComparerInterface
30
    {
31
        return $this->createQueryBuilder('comparer')
32
            ->where('comparer.token = :token')
33
            ->setParameter('token', $token)
34
            ->getQuery()
35
            ->getOneOrNullResult()
36
        ;
37
    }
38
}
39