Completed
Push — master ( 5fe84b...ba5adc )
by Nile
03:05
created

HarvestResourceOwner::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
    public function __construct(array $response = array())
28
    {
29
        $this->response = $response;
30
    }
31
32
    /**
33
     * Get resource owner id
34
     *
35
     * @return string|null
36
     */
37
    public function getId()
38
    {
39
        return $this->response['user']['id'] ?: null;
40
    }
41
42
    /**
43
     * Get resource owner email
44
     *
45
     * @return string|null
46
     */
47
    public function getEmail()
48
    {
49
        return $this->response['user']['email'] ?: null;
50
    }
51
52
    /**
53
     * Get resource owner name
54
     *
55
     * @return string|null
56
     */
57
    public function getName()
58
    {
59
        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
    public function getAvatar()
68
    {
69
        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
    public function setDomain($domain)
80
    {
81
        $this->domain = $domain;
82
83
        return $this;
84
    }
85
86
    /**
87
     * Return all of the owner details available as an array.
88
     *
89
     * @return array
90
     */
91
    public function toArray()
92
    {
93
        return $this->response;
94
    }
95
}
96