Test Setup Failed
Push — master ( 041bc4...5ec0f4 )
by Krister
05:00
created

TraktResourceOwner   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

6 Methods

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