ScopesProviderTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 44
ccs 0
cts 13
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getScopes() 0 4 1
A getScopesString() 0 4 1
A initScopes() 0 4 1
A setScopes() 0 8 2
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\OAuth2\Entity;
9
10
use Doctrine\Common\Collections;
11
12
trait ScopesProviderTrait
13
{
14
    /**
15
     * @var Collections\Collection
16
     */
17
    protected $scopes;
18
19
    /**
20
     * @return array
21
     */
22
    public function getScopes()
23
    {
24
        return $this->scopes->toArray();
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getScopesString()
31
    {
32
        return implode(' ', $this->getScopes());
33
    }
34
35
    /**
36
     * @param Collections\Collection|array $scopes
37
     */
38
    public function setScopes($scopes)
39
    {
40
        if (! $scopes instanceof Collections\Collection) {
41
            $scopes = new Collections\ArrayCollection($scopes);
42
        }
43
44
        $this->scopes = $scopes;
45
    }
46
47
    /**
48
     * initializes an empty array collection, required by Doctrine
49
     * call this in the constructor of each class implementing this trait
50
     */
51
    private function initScopes()
52
    {
53
        $this->scopes = new Collections\ArrayCollection();
54
    }
55
}
56