ZohoUser::getResponseValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Asad\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class ZohoUser implements ResourceOwnerInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $response;
13
14
    /**
15
     * @param array $response
16
     */
17
    public function __construct(array $response)
18
    {
19
        $this->response = $response;
20
    }
21
22
    public function getId()
23
    {
24
        return $this->response['ZUID'];
25
    }
26
27
    public function getZUID()
28
    {
29
        return $this->response['ZUID'];
30
    }
31
32
    /**
33
     * Get preferred display name.
34
     *
35
     * @return string
36
     */
37
    public function getDisplayName()
38
    {
39
        return $this->response['Display_Name'];
40
    }
41
42
    /**
43
     * Get preferred first name.
44
     *
45
     * @return string|null
46
     */
47
    public function getFirstName()
48
    {
49
        return $this->getResponseValue('First_Name');
50
    }
51
52
    /**
53
     * Get preferred last name.
54
     *
55
     * @return string|null
56
     */
57
    public function getLastName()
58
    {
59
        return $this->getResponseValue('Last_Name');
60
    }
61
62
    /**
63
     * Get email address.
64
     *
65
     * @return string|null
66
     */
67
    public function getEmail()
68
    {
69
        return $this->getResponseValue('Email');
70
    }
71
72
    /**
73
     * Get user data as an array.
74
     *
75
     * @return array
76
     */
77
    public function toArray()
78
    {
79
        return $this->response;
80
    }
81
82
    private function getResponseValue($key)
83
    {
84
        if (array_key_exists($key, $this->response)) {
85
            return $this->response[$key];
86
        }
87
        return null;
88
    }
89
}
90