Completed
Push — develop ( 5ce11a...bc30b7 )
by Alexandre
06:55
created

JiraResourceOwner   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 79
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

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