Test Failed
Push — dev ( ccede5...b27119 )
by Herberto
13:46
created

OauthScope   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hasScope() 0 4 2
A jsonSerialize() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Acme\App\Infrastructure\Auth\Authentication\Oauth;
6
7
use League\OAuth2\Server\Entities\ScopeEntityInterface;
8
use League\OAuth2\Server\Entities\Traits\EntityTrait;
9
10
final class OauthScope implements ScopeEntityInterface
11
{
12
    use EntityTrait;
13
14
    /**
15
     * @var array
16
     */
17
    public static $scopes = [];
18
19
    /**
20
     * Scope constructor.
21
     *
22
     * @param $name
23
     */
24
    public function __construct($name)
25
    {
26
        $this->setIdentifier($name);
27
    }
28
29
    /**
30
     * @param $id
31
     *
32
     * @return bool
33
     */
34
    public static function hasScope($id): bool
35
    {
36
        return $id === '*' || array_key_exists($id, static::$scopes);
37
    }
38
39
    /**
40
     * Get the data that should be serialized to JSON.
41
     *
42
     * @return mixed
43
     */
44
    public function jsonSerialize()
45
    {
46
        return $this->getIdentifier();
47
    }
48
}
49