ImgurResourceOwner::getUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace AdamPaterson\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class ImgurResourceOwner implements ResourceOwnerInterface
8
{
9
    /**
10
     * Raw response
11
     *
12
     * @var
13
     */
14
    protected $response;
15
16
    /**
17
     * Creates new resource owner.
18
     *
19
     * @param $response
20
     */
21 3
    public function __construct($response)
22
    {
23 3
        $this->response = $response;
24 3
    }
25
26
    /**
27
     * Get resource owner id
28
     *
29
     * @return string|null
30
     */
31 3
    public function getId()
32
    {
33 3
        return $this->response['data']['id'] ?: null;
34
    }
35
36
    /**
37
     * Return all of the owner details available as an array.
38
     *
39
     * @return array
40
     */
41 3
    public function toArray()
42
    {
43 3
        return $this->response['data'];
44
    }
45
46
    /**
47
     * Get resource owner url
48
     *
49
     * @return string|null
50
     */
51 3
    public function getUrl()
52
    {
53 3
        return $this->response['data']['url'] ?: null;
54
    }
55
56
    /**
57
     * Get Imgur bio
58
     *
59
     * @return mixed
60
     */
61 3
    public function getBio()
62
    {
63 3
        return $this->response['data']['bio'] ?: null;
64
    }
65
66
    /**
67
     * Get resource owner reputation
68
     *
69
     * @return mixed
70
     */
71 3
    public function getReputation()
72
    {
73 3
        return $this->response['data']['reputation'] ?: null;
74
    }
75
76
    /**
77
     * Get created at timestamp
78
     *
79
     * @return string
80
     */
81 3
    public function getCreated()
82
    {
83 3
        return $this->response['data']['created'] ?: null;
84
    }
85
86
    /**
87
     * Get pro account expiration timestamp
88
     *
89
     * @return string
90
     */
91 3
    public function getProExpiration()
92
    {
93 3
        return $this->response['data']['pro_expiration'] ?: null;
94
    }
95
}
96