Completed
Push — master ( 40769e...b59e3f )
by Shaharia
02:09
created

ResourceOwner::getLastName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
/**
3
 * Preview Technologies OAuth2 Resource Owner PHP class
4
 *
5
 * @author Shaharia Azam <[email protected]>
6
 * @url https://www.previewtechs.com
7
 */
8
9
namespace Previewtechs\Oauth2\Client;
10
11
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
12
/**
13
 * Class ResourceOwner
14
 * @package Previewtechs\Oauth2\Client
15
 */
16
class ResourceOwner implements ResourceOwnerInterface
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $response;
22
    /**
23
     * @var array|mixed
24
     */
25
    protected $data = [];
26
    /**
27
     * ResourceOwner constructor.
28
     * @param array $response
29
     */
30
    public function __construct(array $response = array())
31
    {
32
        $this->response = $response;
33
        if (array_key_exists('data', $this->response)) {
34
            $this->data = $this->response['data'];
35
        }
36
    }
37
    /**
38
     * @return null
39
     */
40
    public function getId()
41
    {
42
        return $this->data['id'] ?: null;
43
    }
44
    /**
45
     * @return null
46
     */
47
    public function getEmail()
48
    {
49
        return $this->data['email_address'] ?: null;
50
    }
51
    /**
52
     * @return null
53
     */
54
    public function getFirstName()
55
    {
56
        return $this->data['profile']['first_name'] ?: null;
57
    }
58
    /**
59
     * @return null
60
     */
61
    public function getLastName()
62
    {
63
        return $this->data['profile']['last_name'] ?: null;
64
    }
65
    /**
66
     * @return null
67
     */
68
    public function getFullName()
69
    {
70
        return $this->data['profile']['full_name'] ?: null;
71
    }
72
    /**
73
     * @return null
74
     */
75
    public function getPicture()
76
    {
77
        return $this->data['profile']['picture'] ?: null;
78
    }
79
    /**
80
     * @return null
81
     */
82
    public function getGender()
83
    {
84
        return $this->data['profile']['gender'] ?: null;
85
    }
86
    /**
87
     * @return array
88
     */
89
    public function toArray()
90
    {
91
        return $this->response;
92
    }
93
}