HarvestResourceOwner   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 90
ccs 16
cts 16
cp 1
rs 10

7 Methods

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