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

IdCardRepository::findPersonIdCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
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