Completed
Push — master ( 030cac...d27166 )
by Derek Stephen
03:11
created

ScopeRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 41.67%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 47
ccs 5
cts 12
cp 0.4167
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
A save() 0 4 1
A finalizeScopes() 0 4 1
A getScopeEntityByIdentifier() 0 5 1
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 1
    public function getScopeEntityByIdentifier($identifier)
18
    {
19
        /** @var Scope $scope */
20 1
        $scope = $this->findOneBy(['identifier' => $identifier]);
21 1
        return $scope;
22
    }
23
24
    /**
25
     * @param array|ScopeEntityInterface[] $scopes
26
     * @param string $grantType
27
     * @param ClientEntityInterface $clientEntity
28
     * @param null|string|null $userIdentifier
29
     * @return Scope[]
30
     */
31 1
    public function finalizeScopes(array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null)
32
    {
33
        /** @todo code in further ACL functionality in here specific to our app */
34 1
        return $scopes;
35
    }
36
37
    /**
38
     * @param Scope $scope
39
     * @return Scope
40
     * @throws \Doctrine\ORM\OptimisticLockException
41
     */
42
    public function create(Scope $scope)
43
    {
44
        $this->_em->persist($scope);
45
        $this->_em->flush($scope);
46
        return $scope;
47
    }
48
49
    /**
50
     * @param Scope $scope
51
     * @return Scope
52
     * @throws \Doctrine\ORM\OptimisticLockException
53
     */
54
    public function save(Scope $scope)
55
    {
56
        $this->_em->flush($scope);
57
        return $scope;
58
    }
59
}