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

RemoteClaimRepository::findByClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
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\RemoteClaimInterface;
17
18
/**
19
 * Class RemoteClaimRepository
20
 * @package LoginCidadao\RemoteClaimsBundle\Entity
21
 *
22
 * @codeCoverageIgnore
23
 */
24
class RemoteClaimRepository extends EntityRepository
25
{
26
    /**
27
     * @param ClientInterface $client
28
     * @return array|RemoteClaimInterface[]
29
     */
30
    public function findByClient(ClientInterface $client)
31
    {
32
        return $this->createQueryBuilder('r')
33
            ->where('r.provider = :client')
34
            ->setParameter('client', $client)
35
            ->getQuery()
36
            ->getResult();
37
    }
38
39
    public function findByClientAndPerson(ClientInterface $client, PersonInterface $person)
40
    {
41
        return $this->createQueryBuilder('r')
42
            ->select('r')
43
            ->innerJoin(
44
                'LoginCidadaoRemoteClaimsBundle:RemoteClaimAuthorization',
45
                'a', 'WITH', 'a.client = :client AND a.person = :person'
46
            )
47
            ->where('a.claimName = r.name')
48
            ->setParameters([
49
                'client' => $client,
50
                'person' => $person,
51
            ])
52
            ->getQuery()
53
            ->getResult();
54
    }
55
}
56