Failed Conditions
Pull Request — master (#790)
by Guilherme
18:22 queued 13:16
created

RemoteClaimAuthorizationRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findAllByClientAndPerson() 0 11 1
A findAuthorization() 0 13 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\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