Completed
Pull Request — master (#887)
by
unknown
02:49
created

ScopeEntityTrait::addScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace League\OAuth2\Server\Entities\Traits;
4
5
use League\OAuth2\Server\Entities\ScopeEntityInterface;
6
7
trait ScopeEntityTrait
8
{
9
    /**
10
     * @var ScopeEntityInterface[]
11
     */
12
    protected $scopes = [];
13
14
    /**
15
     * Associate a scope with the token.
16
     *
17
     * @param ScopeEntityInterface $scope
18
     */
19 17
    public function addScope(ScopeEntityInterface $scope)
20
    {
21 17
        $this->scopes[$scope->getIdentifier()] = $scope;
22 17
    }
23
24
    /**
25
     * Return an array of scopes associated with the token.
26
     *
27
     * @return ScopeEntityInterface[]
28
     */
29 13
    public function getScopes()
30
    {
31 13
        return array_values($this->scopes);
32
    }
33
}
34