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

AffiliateViewRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A countViewsByCustomer() 0 9 1
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