Completed
Branch develop (6fd611)
by Quentin
02:32
created

ApplicationLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 0
cbo 0
dl 0
loc 33
ccs 0
cts 16
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A retrieveByApiKeyAndSecret() 0 12 1
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