WishlistRepository::findOneByShopUser()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusWishlistPlugin\Repository;
12
13
use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface;
14
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
15
use Sylius\Component\Core\Model\ShopUserInterface;
16
17
class WishlistRepository extends EntityRepository implements WishlistRepositoryInterface
18
{
19
    public function findOneByShopUser(ShopUserInterface $shopUser): ?WishlistInterface
20
    {
21
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return BitBag\SyliusWishlistPlu...\WishlistInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
22
            ->where('o.shopUser = :shopUser')
23
            ->setParameter('shopUser', $shopUser)
24
            ->getQuery()
25
            ->getOneOrNullResult()
26
        ;
27
    }
28
29
    public function findByToken(string $token): ?WishlistInterface
30
    {
31
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return BitBag\SyliusWishlistPlu...\WishlistInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
32
            ->where('o.token = :token')
33
            ->setParameter('token', $token)
34
            ->getQuery()
35
            ->getOneOrNullResult()
36
        ;
37
    }
38
}
39