OAuth2Token::getProviderKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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