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

OauthScope::hasScope()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 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