Completed
Push — master ( aef04b...0c132b )
by Patrick
01:11
created

AppleResourceOwner::getEmail()   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 4
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
12
    use ArrayAccessorTrait;
13
14
    /**
15
     * Raw response
16
     *
17
     * @var array
18
     */
19
    protected $response = [];
20
21
    /**
22
     * @var string|null
23
     */
24
    private $email;
25
26
    /**
27
     * Gets resource owner attribute by key. The key supports dot notation.
28
     *
29
     * @return mixed
30
     */
31
    public function getAttribute($key)
32
    {
33
        return $this->getValueByKey($this->response, (string) $key);
34
    }
35
36
    /**
37
     * Get user first name
38
     *
39
     * @return string|null
40
     */
41
    public function getFirstName()
42
    {
43
        return $this->getAttribute('name')['firstName'];
44
    }
45
46
    /**
47
     * Get user user id
48
     *
49
     * @return string|null
50
     */
51
    public function getId()
52
    {
53
        return $this->resourceOwnerId;
54
    }
55
56
    /**
57
     * Get user last name
58
     *
59
     * @return string|null
60
     */
61
    public function getLastName()
62
    {
63
        return $this->getAttribute('name')['lastName'];
64
    }
65
66
    /**
67
     * Get user email, if available
68
     *
69
     * @return string|null
70
     */
71
    public function getEmail()
72
    {
73
        return $this->getAttribute('email');
74
    }
75
76
    /**
77
     * Return all of the owner details available as an array.
78
     *
79
     * @return array
80
     */
81
    public function toArray()
82
    {
83
        return $this->response;
84
    }
85
}
86