OAuth2Token   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 3
A getCredentials() 0 4 1
A getProviderKey() 0 4 1
A getClient() 0 4 1
1
<?php
2
3
namespace TH\OAuth2;
4
5
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
6
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
7
8
class OAuth2Token extends AbstractToken implements TokenInterface
9
{
10
    private $credentials;
11
    private $providerKey;
12
    private $client;
13
14
    public function __construct($client, $user, $credentials, $providerKey, array $roles = [], array $scopes = [])
15
    {
16
        parent::__construct($roles);
17
18
        $this->client = $client;
19
20
        if (empty($providerKey)) {
21
            throw new \InvalidArgumentException('$providerKey must not be empty.');
22
        }
23
24
        if (null !== $user) {
25
            $this->setUser($user);
26
        }
27
        $this->credentials = $credentials;
28
        $this->providerKey = $providerKey;
29
        $this->setAttribute('scopes', $scopes);
30
31
        $this->setAuthenticated(count($roles) > 0);
32
    }
33
34
35
    public function getCredentials()
36
    {
37
        return $this->credentials;
38
    }
39
40
    public function getProviderKey()
41
    {
42
        return $this->providerKey;
43
    }
44
45
    public function getClient()
46
    {
47
        return $this->client;
48
    }
49
}
50