ApiCallRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadReadyCalls() 0 15 1
A findNormalCallsByKey() 0 14 1
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Entity;
3
4
use Doctrine\ORM\EntityRepository;
5
6
class ApiCallRepository extends EntityRepository
7
{
8
9
    public function loadReadyCalls()
10
    {
11
        $qb = $this->createQueryBuilder('ac');
12
        $q = $qb->select('ac', 'a')
13
            ->join('ac.api', 'a')
14
            ->where(
15
                'ac.active = true
16
                and (ac.cachedUntil is null or ac.cachedUntil <= :date)
17
                and (ac.earliestNextCall is null or ac.earliestNextCall <= :date)'
18
            )
19
            ->setParameter('date', new \DateTime('now', new \DateTimeZone('UTC')))
20
            ->getQuery();
21
22
        return $q->getResult();
23
    }
24
25
    public function findNormalCallsByKey(ApiKey $key)
26
    {
27
        $qb = $this->createQueryBuilder('ac');
28
        $q = $qb->select('ac', 'a')
29
            ->join('ac.api', 'a')
30
            ->where(
31
                'ac.key = :key
32
                and a.mask is not null'
33
            )
34
            ->setParameter('key', $key)
35
            ->getQuery();
36
37
        return $q->getResult();
38
    }
39
}
40