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

ScopeRepository::finalizeScopes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 4
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
}