ApiRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadValidApis() 0 20 2
A loadApiKeyInfoApi() 0 13 1
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Entity;
3
4
use Doctrine\ORM\EntityRepository;
5
6
class ApiRepository extends EntityRepository
7
{
8
    public function loadValidApis($accessMask, $keyType)
9
    {
10
        if ($keyType == 'Corporation') {
11
            $corpRestriction = 'a.section = :corpSection';
12
        } else {
13
            $corpRestriction = 'a.section <> :corpSection';
14
        }
15
16
        $qb = $this->createQueryBuilder('a');
17
        $q = $qb->select('a')
18
            ->where(
19
                'BIT_AND(a.mask, :accessMask) = a.mask
20
                and ' . $corpRestriction
21
            )
22
            ->getQuery()
23
            ->setParameter('accessMask', $accessMask)
24
            ->setParameter('corpSection', 'corp');
25
26
        return $q->getResult();
27
    }
28
29
    public function loadApiKeyInfoApi()
30
    {
31
        $qb = $this->createQueryBuilder('a');
32
        $q = $qb->select('a')
33
            ->where(
34
                'a.section = :section and a.name = :name'
35
            )
36
            ->setParameter('section', 'account')
37
            ->setParameter('name', 'APIKeyInfo')
38
            ->getQuery();
39
40
        return $q->getSingleResult();
41
    }
42
}
43