ApplicationLoader::retrieveByApiKeyAndSecret()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 12
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Majora\Component\OAuth\Loader\ORM;
4
5
use Majora\Component\OAuth\Loader\ApplicationLoaderInterface;
6
use Majora\Component\OAuth\Repository\ORM\ApplicationRepository;
7
8
/**
9
 * ORM Application loading implementation.
10
 */
11
class ApplicationLoader implements ApplicationLoaderInterface
12
{
13
    /**
14
     * @var ApplicationRepository
15
     */
16
    protected $applicationRepository;
17
18
    /**
19
     * Construct.
20
     *
21
     * @param ApplicationRepository $applicationRepository
22
     */
23
    public function __construct(ApplicationRepository $applicationRepository)
24
    {
25
        $this->applicationRepository = $applicationRepository;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function retrieveByApiKeyAndSecret($apiKey, $secret)
32
    {
33
        return $this->applicationRepository
34
            ->createQueryBuilder('a')
35
                ->where('a.secret = :secret')
36
                    ->setParameter('secret', $secret)
37
                ->andWhere('a.apiKey = :api_key')
38
                    ->setParameter('api_key', $apiKey)
39
            ->getQuery()
40
                ->getOneOrNullResult()
41
        ;
42
    }
43
}
44