ZohoUser::getEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
4
namespace ShahariaAzam\ZohoOAuth2\Client\Provider;
5
6
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
7
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
8
9
/**
10
 * Class ZohoUser
11
 * @package ShahariaAzam\ZohoOAuth2\Client\Provider
12
 */
13
class ZohoUser implements ResourceOwnerInterface
14
{
15
    use ArrayAccessorTrait;
16
17
    /**
18
     * @var array
19
     */
20
    protected $response = [];
21
22
    /**
23
     * ZohoUser constructor.
24
     * @param array $response
25
     */
26
    public function __construct(array $response)
27
    {
28
        $this->response = $response;
29
    }
30
31
    /**
32
     * Returns the identifier of the authorized resource owner.
33
     *
34
     * @return mixed
35
     */
36
    public function getId()
37
    {
38
        return $this->getResponseData('ZUID');
39
    }
40
41
    /**
42
     * @param $path
43
     * @param null $default
44
     * @return mixed
45
     */
46
    protected function getResponseData($path, $default = null)
47
    {
48
        return $this->getValueByKey($this->response, $path, $default);
49
    }
50
51
    /**
52
     * @return string|null
53
     */
54
    public function getFirstName()
55
    {
56
        return $this->getResponseData('First_Name');
57
    }
58
59
    /**
60
     * @return string|null
61
     */
62
    public function getLastName()
63
    {
64
        return $this->getResponseData('Last_Name');
65
    }
66
67
    /**
68
     * @return string|null
69
     */
70
    public function getEmail()
71
    {
72
        return $this->getResponseData('Email');
73
    }
74
75
    /**
76
     * @return string|null
77
     */
78
    public function getDisplayName()
79
    {
80
        return $this->getResponseData('Display_Name');
81
    }
82
83
    /**
84
     * @return string|null
85
     */
86
    public function getPicture()
87
    {
88
        return null;
89
    }
90
91
    /**
92
     * Return all of the owner details available as an array.
93
     *
94
     * @return array
95
     */
96
    public function toArray()
97
    {
98
        return [
99
            'first_name' => $this->getResponseData("First_Name"),
100
            'last_name' => $this->getResponseData("First_Name"),
101
            'display_name' => $this->getResponseData("Display_Name"),
102
            'email' => $this->getResponseData("Email"),
103
            'id' => $this->getResponseData("ZUID"),
104
        ];
105
    }
106
}
107