WecounselResourceOwner   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 64
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

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