AppleResourceOwner::getEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php namespace League\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
4
5
/**
6
 * @property array $response
7
 * @property string $uid
8
 */
9
class AppleResourceOwner extends GenericResourceOwner
10
{
11
    use ArrayAccessorTrait;
12
13
    /**
14
     * Raw response
15
     *
16
     * @var array
17
     */
18
    protected $response = [];
19
20
    /**
21
     * @var string|null
22
     */
23
    private $email;
24
25
    /**
26
     * @var boolean true when its private relay from apple else the user mail address
27
     */
28
    private $isPrivateEmail;
29
30
    /**
31
     * Gets resource owner attribute by key. The key supports dot notation.
32
     *
33
     * @param string $key
34
     *
35
     * @return mixed
36
     */
37 1
    public function getAttribute($key)
38
    {
39 1
        return $this->getValueByKey($this->response, (string) $key);
40
    }
41
42
    /**
43
     * Get user first name
44
     *
45
     * @return string|null
46
     */
47 1
    public function getFirstName()
48
    {
49 1
        $name = $this->getAttribute('name');
50 1
        if (isset($name)) {
51 1
            return $name['firstName'];
52
        }
53
        return null;
54
    }
55
56
    /**
57
     * Get user user id
58
     *
59
     * @return string|null
60
     */
61 1
    public function getId()
62
    {
63 1
        return $this->resourceOwnerId;
64
    }
65
66
    /**
67
     * Get user last name
68
     *
69
     * @return string|null
70
     */
71 1
    public function getLastName()
72
    {
73 1
        $name = $this->getAttribute('name');
74 1
        if (isset($name)) {
75 1
            return $name['lastName'];
76
        }
77
        return null;
78
    }
79
80
    /**
81
     * Get user email, if available
82
     *
83
     * @return string|null
84
     */
85 1
    public function getEmail()
86
    {
87 1
        return $this->getAttribute('email');
88
    }
89
90
    /**
91
     * @return bool
92
     */
93 1
    public function isPrivateEmail()
94
    {
95 1
        return (bool) $this->getAttribute('isPrivateEmail');
96
    }
97
98
    /**
99
     * Return all of the owner details available as an array.
100
     *
101
     * @return array
102
     */
103 1
    public function toArray()
104
    {
105 1
        return $this->response;
106
    }
107
}
108