BasecampResourceOwner::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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