Passed
Push — master ( a403c4...843515 )
by Diego
07:39 queued 01:51
created

AffiliateViewRepository::countViewsByCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusReferralsPlugin\Repository;
6
7
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
8
use Sylius\Component\Core\Model\CustomerInterface;
9
10
class AffiliateViewRepository extends EntityRepository implements AffiliateViewRepositoryInterface
11
{
12
    public function countViewsByCustomer(CustomerInterface $customer): int
13
    {
14
        return (int) $this->createQueryBuilder('o')
15
            ->select('COUNT(o.id)')
16
            ->innerJoin('o.affiliate', 'a')
17
            ->andWhere('a.customer = :customer')
18
            ->setParameter('customer', $customer)
19
            ->getQuery()
20
            ->getSingleScalarResult()
21
        ;
22
    }
23
}
24