LinodeResourceOwner   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 110
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0
wmc 13

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getTaxId() 0 3 1
A getLastName() 0 3 1
A getAddress() 0 10 2
A __construct() 0 3 1
A getFirstName() 0 3 1
A getCreditCard() 0 3 1
A getPhone() 0 3 1
A getCompany() 0 3 1
A toArray() 0 3 1
A getBalance() 0 3 1
A getEmail() 0 3 1
A getId() 0 3 1
1
<?php
2
3
//----------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <http://opensource.org/licenses/MIT>.
9
//
10
//----------------------------------------------------------------------
11
12
namespace Linode\OAuth2\Client\Provider;
13
14
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
15
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
16
17
/**
18
 * Linode OAuth account details.
19
 */
20
class LinodeResourceOwner implements ResourceOwnerInterface
21
{
22
    use ArrayAccessorTrait;
23
24
    /** @var array */
25
    protected $response;
26
27
    /**
28
     * Creates new resource owner.
29
     *
30
     * @param array $response
31
     */
32 12
    public function __construct(array $response = [])
33
    {
34 12
        $this->response = $response;
35 12
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function getId()
41
    {
42 1
        return null;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    public function toArray()
49
    {
50 1
        return $this->response;
51
    }
52
53
    /**
54
     * @return string
55
     */
56 1
    public function getFirstName()
57
    {
58 1
        return $this->getValueByKey($this->response, 'first_name');
59
    }
60
61
    /**
62
     * @return string
63
     */
64 1
    public function getLastName()
65
    {
66 1
        return $this->getValueByKey($this->response, 'last_name');
67
    }
68
69
    /**
70
     * @return string
71
     */
72 1
    public function getEmail()
73
    {
74 1
        return $this->getValueByKey($this->response, 'email');
75
    }
76
77
    /**
78
     * @return string
79
     */
80 1
    public function getCompany()
81
    {
82 1
        return $this->getValueByKey($this->response, 'company');
83
    }
84
85
    /**
86
     * @return array
87
     */
88 1
    public function getAddress()
89
    {
90 1
        $keys = ['address_1', 'address_2', 'city', 'state', 'country', 'zip'];
91 1
        $data = [];
92
93 1
        foreach ($keys as $key) {
94 1
            $data[$key] = $this->getValueByKey($this->response, $key);
95
        }
96
97 1
        return $data;
98
    }
99
100
    /**
101
     * @return string
102
     */
103 1
    public function getPhone()
104
    {
105 1
        return $this->getValueByKey($this->response, 'phone');
106
    }
107
108
    /**
109
     * @return string
110
     */
111 1
    public function getTaxId()
112
    {
113 1
        return $this->getValueByKey($this->response, 'tax_id');
114
    }
115
116
    /**
117
     * @return string
118
     */
119 1
    public function getBalance()
120
    {
121 1
        return $this->getValueByKey($this->response, 'balance');
122
    }
123
124
    /**
125
     * @return array
126
     */
127 1
    public function getCreditCard()
128
    {
129 1
        return $this->getValueByKey($this->response, 'credit_card');
130
    }
131
}
132