TraktResourceOwner   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 71
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUsername() 0 4 1
A getName() 0 4 1
A getAvatarUrl() 0 4 1
A getId() 0 4 1
A toArray() 0 4 1
A __construct() 0 4 1
1
<?php namespace Bogstag\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
4
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
5
6
class TraktResourceOwner implements ResourceOwnerInterface
7
{
8
    use ArrayAccessorTrait;
9
10
    /**
11
     * Raw response
12
     *
13
     * @var array
14
     */
15
    protected $response;
16
17
    /**
18
     * Creates new resource owner.
19
     *
20
     * @param array $response
21
     */
22 3
    public function __construct(array $response = [])
23
    {
24 3
        $this->response = $response;
25 3
    }
26
27
    /**
28
     * Get username
29
     *
30
     * @return string|null
31
     */
32 3
    public function getUsername()
33
    {
34 3
        return $this->getValueByKey($this->response, 'user.username');
35
    }
36
37
    /**
38
     * Get user name
39
     *
40
     * @return string|null
41
     */
42 3
    public function getName()
43
    {
44 3
        return $this->getValueByKey($this->response, 'user.name');
45
    }
46
47
    /**
48
     * Get user avatar url
49
     *
50
     * @return string|null
51
     */
52 3
    public function getAvatarUrl()
53
    {
54 3
        return $this->getValueByKey($this->response, 'user.images.avatar.full');
55
    }
56
57
    /**
58
     * Get user slug
59
     *
60
     * @return string|null
61
     */
62 3
    public function getId()
63
    {
64 3
        return $this->getValueByKey($this->response, 'user.ids.slug');
65
    }
66
67
    /**
68
     * Return all of the owner details available as an array.
69
     *
70
     * @return array
71
     */
72 3
    public function toArray()
73
    {
74 3
        return $this->response;
75
    }
76
}
77