BasecampResourceOwner   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 62
ccs 13
cts 13
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getEmail() 0 3 1
A __construct() 0 3 1
A getName() 0 5 1
A toArray() 0 3 1
1
<?php
2
3
namespace Stevenmaguire\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
7
8
class BasecampResourceOwner 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 2
    public function __construct(array $response = array())
25
    {
26 2
        $this->response = $response;
27 2
    }
28
29
    /**
30
     * Get resource owner id
31
     *
32
     * @return string|null
33
     */
34 2
    public function getId()
35
    {
36 2
        return $this->getValueByKey($this->response, 'identity.id');
37
    }
38
39
    /**
40
     * Get resource owner name
41
     *
42
     * @return string
43
     */
44 2
    public function getName()
45
    {
46 2
        return implode(' ', array_filter([
47 2
            $this->getValueByKey($this->response, 'identity.first_name'),
48 2
            $this->getValueByKey($this->response, 'identity.last_name')
49
        ]));
50
    }
51
52
    /**
53
     * Get resource owner email
54
     *
55
     * @return string|null
56
     */
57 2
    public function getEmail()
58
    {
59 2
        return $this->getValueByKey($this->response, 'identity.email_address');
60
    }
61
62
    /**
63
     * Return all of the owner details available as an array.
64
     *
65
     * @return array
66
     */
67 2
    public function toArray()
68
    {
69 2
        return $this->response;
70
    }
71
}
72