DrupalResourceOwner::getZoneInfo()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace ChrisHemmings\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class DrupalResourceOwner implements ResourceOwnerInterface
8
{
9
    /**
10
     * Raw response
11
     *
12
     * @var
13
     */
14
    protected $response;
15
16
    /**
17
     * Creates new resource owner.
18
     *
19
     * @param array $response
20
     */
21 3
    public function __construct(array $response)
22
    {
23 3
        $this->response = $response;
24 3
    }
25
26
    /**
27
     * Get resource owner id
28
     *
29
     * @return string|null
30
     */
31 3
    public function getId()
32
    {
33 3
        return $this->response['sub'] ?: null;
34
    }
35
36
    /**
37
     * Return all of the owner details available as an array.
38
     *
39
     * @return array
40
     */
41 3
    public function toArray()
42
    {
43 3
        return $this->response;
44
    }
45
46
    /**
47
     * Get emailaddress
48
     *
49
     * @return string|null
50
     */
51 3
    public function getEmail()
52
    {
53 3
        return $this->response['email'] ?: null;
54
    }
55
56
    /**
57
     * Get email verified
58
     *
59
     * @return bool
60
     */
61 3
    public function isEmailVerified()
62
    {
63 3
        return (bool) $this->response['email_verified'] ?: false;
64
    }
65
66
    /**
67
     * Get name
68
     *
69
     * @return string|null
70
     */
71 3
    public function getName()
72
    {
73 3
        return $this->response['name'] ?: null;
74
    }
75
76
    /**
77
     * Get name
78
     *
79
     * @return string|null
80
     */
81 3
    public function getPreferredName()
82
    {
83 3
        return $this->response['preferred_username'] ?: null;
84
    }
85
86
    /**
87
     * Get name
88
     *
89
     * @return string|null
90
     */
91 3
    public function getZoneInfo()
92
    {
93 3
        return $this->response['zoneinfo'] ?: null;
94
    }
95
}
96