Completed
Push — issue#666 ( 928a8e...2654e9 )
by Guilherme
04:24
created

findAllByClientAndPerson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 2
dl 0
loc 12
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
30
     */
31
    public function findAuthorization(RemoteClaimAuthorizationInterface $authorization)
32
    {
33
        return $this->createQueryBuilder('a')
34
            ->where('a.claimName = :name')
35
            ->andWhere('a.client = :client')
36
            ->andWhere('a.person = :person')
37
            ->setParameters([
38
                'name' => $authorization->getClaimName(),
39
                'client' => $authorization->getClient(),
40
                'person' => $authorization->getPerson(),
41
            ])
42
            ->getQuery()
43
            ->getOneOrNullResult();
44
    }
45
46
    public function findAllByClientAndPerson(ClientInterface $client, PersonInterface $person)
47
    {
48
        return $this->createQueryBuilder('a')
49
            ->where('a.client = :client')
50
            ->andWhere('a.person = :person')
51
            ->setParameters([
52
                'client' => $client,
53
                'person' => $person,
54
            ])
55
            ->getQuery()
56
            ->getResult();
57
    }
58
}
59