Completed
Push — master ( 0c132b...2e079d )
by Patrick
02:37
created

AppleResourceOwner::isPrivateEmail()   A

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 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
        return $this->getAttribute('name')['firstName'];
50
    }
51
52
    /**
53
     * Get user user id
54
     *
55
     * @return string|null
56
     */
57 1
    public function getId()
58
    {
59 1
        return $this->resourceOwnerId;
60
    }
61
62
    /**
63
     * Get user last name
64
     *
65
     * @return string|null
66
     */
67 1
    public function getLastName()
68
    {
69 1
        return $this->getAttribute('name')['lastName'];
70
    }
71
72
    /**
73
     * Get user email, if available
74
     *
75
     * @return string|null
76
     */
77 1
    public function getEmail()
78
    {
79 1
        return $this->getAttribute('email');
80
    }
81
82
    /**
83
     * @return bool
84
     */
85
    public function isPrivateEmail()
86
    {
87
        return $this->getAttribute('isPrivateEmail');
88
    }
89
90
    /**
91
     * Return all of the owner details available as an array.
92
     *
93
     * @return array
94
     */
95
    public function toArray()
96
    {
97
        return $this->response;
98
    }
99
}
100