Passed
Push — master ( 99e9d5...233c5a )
by Derek Stephen
09:09
created

ScopeRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 50
rs 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
A finalizeScopes() 0 4 1
A save() 0 4 1
A getScopeEntityByIdentifier() 0 8 2
1
<?php
2
3
namespace OAuth\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use League\OAuth2\Server\Entities\ClientEntityInterface;
7
use League\OAuth2\Server\Entities\ScopeEntityInterface;
8
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
9
use OAuth\Scope;
10
11
class ScopeRepository extends EntityRepository implements ScopeRepositoryInterface
12
{
13
    /**
14
     * @param string $identifier
15
     * @return null|Scope
16
     */
17
    public function getScopeEntityByIdentifier($identifier)
18
    {
19
        $qb = $this->createQueryBuilder('s');
20
        $qb->where('s.identifier = :id');
21
        $qb->setParameter('id', $identifier);
22
        $query = $qb->getQuery();
23
        $result = $query->getResult();
24
        return empty($result) ? null : $result[0];
25
    }
26
27
    /**
28
     * @param array|ScopeEntityInterface[] $scopes
29
     * @param string $grantType
30
     * @param ClientEntityInterface $clientEntity
31
     * @param null|string|null $userIdentifier
32
     * @return Scope[]
33
     */
34
    public function finalizeScopes(array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null)
35
    {
36
        // TODO: Implement finalizeScopes() method.
37
        return $scopes; // until we figure out what we need to do in here
38
    }
39
40
    /**
41
     * @param Scope $scope
42
     * @return Scope
43
     * @throws \Doctrine\ORM\OptimisticLockException
44
     */
45
    public function create(Scope $scope)
46
    {
47
        $this->_em->persist($scope);
48
        $this->_em->flush($scope);
49
        return $scope;
50
    }
51
52
    /**
53
     * @param Scope $scope
54
     * @return Scope
55
     * @throws \Doctrine\ORM\OptimisticLockException
56
     */
57
    public function save(Scope $scope)
58
    {
59
        $this->_em->flush($scope);
60
        return $scope;
61
    }
62
}