AccountLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
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 34
ccs 0
cts 17
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A retrieveOnApplicationByUsername() 0 13 1
1
<?php
2
3
namespace Majora\Component\OAuth\Loader\ORM;
4
5
use Majora\Component\OAuth\Loader\AccountLoaderInterface;
6
use Majora\Component\OAuth\Model\ApplicationInterface;
7
use Majora\Component\OAuth\Repository\ORM\AccountRepository;
8
9
/**
10
 * ORM Account loading implementation.
11
 */
12
class AccountLoader implements AccountLoaderInterface
13
{
14
    /**
15
     * @var AccountRepository
16
     */
17
    protected $accountRepository;
18
19
    /**
20
     * Construct.
21
     *
22
     * @param AccountRepository $accountRepository
23
     */
24
    public function __construct(AccountRepository $accountRepository)
25
    {
26
        $this->accountRepository = $accountRepository;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function retrieveOnApplicationByUsername(ApplicationInterface $application, $username)
33
    {
34
        return $this->accountRepository
35
            ->createQueryBuilder('ac')
36
                ->innerJoin('ac.applications', 'app')
37
                ->where('ac.username = :username')
38
                    ->setParameter('username', $username)
39
                ->andWhere('app.id = :application')
40
                    ->setParameter('application', $application->getId())
41
            ->getQuery()
42
                ->getOneOrNullResult()
43
        ;
44
    }
45
}
46