EpicGamesResourceOwner::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MrPropre\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
7
8
class EpicGamesResourceOwner implements ResourceOwnerInterface
9
{
10
    use ArrayAccessorTrait;
11
12
    /**
13
     * @var array
14
     */
15
    protected $response;
16
17
    /**
18
     * Creates new resource owner.
19
     */
20 1
    public function __construct(array $response = [])
21
    {
22 1
        $this->response = $response;
23 1
    }
24
25
    /**
26
     * Get resource owner ID
27
     */
28 1
    public function getId(): ?string
29
    {
30 1
        return $this->getValueByKey($this->response, 'sub');
31
    }
32
33
    /**
34
     * Get resource owner username
35
     */
36 1
    public function getUsername(): ?string
37
    {
38 1
        return $this->getValueByKey($this->response, 'preferred_username');
39
    }
40
41
    /**
42
     * Returns the raw resource owner response.
43
     */
44 1
    public function toArray(): array
45
    {
46 1
        return $this->response;
47
    }
48
}
49