HerokuResourceOwner   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
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 74
c 0
b 0
f 0
ccs 13
cts 13
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A getEmail() 0 4 1
A getResponseData() 0 4 1
A toArray() 0 4 1
1
<?php namespace Stevenmaguire\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
4
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
5
6
class HerokuResourceOwner 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 2
    public function __construct(array $response = array())
23
    {
24 2
        $this->response = $response;
25 2
    }
26
27
    /**
28
     * Get user id
29
     *
30
     * @return string|null
31
     */
32 2
    public function getId()
33
    {
34 2
        return $this->getResponseData('id');
35
    }
36
37
    /**
38
     * Get user name
39
     *
40
     * @return string|null
41
     */
42 2
    public function getName()
43
    {
44 2
        return $this->getResponseData('name');
45
    }
46
47
    /**
48
     * Get user email
49
     *
50
     * @return string|null
51
     */
52 2
    public function getEmail()
53
    {
54 2
        return $this->getResponseData('email');
55
    }
56
57
    /**
58
     * Attempts to pull value from array using dot notation.
59
     *
60
     * @param string $path
61
     * @param string $default
62
     *
63
     * @return mixed
64
     */
65 2
    protected function getResponseData($path, $default = null)
66
    {
67 2
        return $this->getValueByKey($this->response, $path, $default);
68
    }
69
70
    /**
71
     * Return all of the owner details available as an array.
72
     *
73
     * @return array
74
     */
75 2
    public function toArray()
76
    {
77 2
        return $this->response;
78
    }
79
}
80