Failed Conditions
Push — issue#702_rs ( ed72a1...cdafcf )
by Guilherme
07:33
created

findAllByClientAndPerson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 11
rs 9.4285
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\RemoteClaimsBundle\Entity;
12
13
use Doctrine\ORM\EntityRepository;
14
use LoginCidadao\CoreBundle\Model\PersonInterface;
15
use LoginCidadao\OAuthBundle\Model\ClientInterface;
16
use LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimAuthorizationInterface;
17
use LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimInterface;
18
19
/**
20
 * Class RemoteClaimAuthorizationRepository
21
 * @package LoginCidadao\RemoteClaimsBundle\Entity
22
 *
23
 * @codeCoverageIgnore
24
 */
25
class RemoteClaimAuthorizationRepository extends EntityRepository
26
{
27
    /**
28
     * @param RemoteClaimAuthorizationInterface $authorization
29
     * @return RemoteClaimAuthorizationInterface|null
30
     * @throws \Doctrine\ORM\NonUniqueResultException
31
     */
32
    public function findAuthorization(RemoteClaimAuthorizationInterface $authorization)
33
    {
34
        return $this->createQueryBuilder('a')
35
            ->where('a.claimName = :name')
36
            ->andWhere('a.client = :client')
37
            ->andWhere('a.person = :person')
38
            ->setParameters([
39
                'name' => $authorization->getClaimName(),
40
                'client' => $authorization->getClient(),
41
                'person' => $authorization->getPerson(),
42
            ])
43
            ->getQuery()
44
            ->getOneOrNullResult();
45
    }
46
47
    public function findAllByClientAndPerson(ClientInterface $client, PersonInterface $person)
48
    {
49
        return $this->createQueryBuilder('a')
50
            ->where('a.client = :client')
51
            ->andWhere('a.person = :person')
52
            ->setParameters([
53
                'client' => $client,
54
                'person' => $person,
55
            ])
56
            ->getQuery()
57
            ->getResult();
58
    }
59
}
60