Failed Conditions
Push — issue#808 ( 868db7...3c2936 )
by Guilherme
07:23
created

IdCardRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 34
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findByPersonOrderByStateAcronym() 0 10 1
A findPersonIdCard() 0 5 1
A getGridQuery() 0 11 1
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\CoreBundle\Entity;
12
13
use Doctrine\ORM\EntityRepository;
14
use LoginCidadao\CoreBundle\Model\PersonInterface;
15
16
class IdCardRepository extends EntityRepository
17
{
18
19
    public function getGridQuery(PersonInterface $person)
20
    {
21
        $qb = $this->createQueryBuilder('u')
22
            ->select('u.id, u.value, right(s.iso6, 2) iso6')
23
            ->join('LoginCidadaoCoreBundle:State', 's', 'with',
24
                    'u.state = s')
25
            ->where('u.person = :person')
26
            ->setParameters(array('person' => $person))
27
            ->orderBy('u.id', 'desc');
28
29
        return $qb;
30
    }
31
32
    public function findPersonIdCard(PersonInterface $person, $id)
33
    {
34
        return $this->findOneBy(array(
35
                'person' => $person,
36
                'id' => $id
37
        ));
38
    }
39
40
    public function findByPersonOrderByStateAcronym(PersonInterface $person)
41
    {
42
        $qb = $this->createQueryBuilder('i')
43
            ->join('LoginCidadaoCoreBundle:State', 's', 'with',
44
                    'i.state = s')
45
            ->where('i.person = :person')
46
            ->setParameters(array('person' => $person))
47
            ->orderBy('s.acronym', 'asc');
48
49
        return $qb->getQuery()->getResult();
50
    }
51
52
}
53