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

ScopeRepository::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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