Completed
Push — master ( 6c2dd9...ca8e19 )
by Eric
03:03
created

KeycloakResourceOwner::getName()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Makuro\Directus\KeycloakClient\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class KeycloakResourceOwner implements ResourceOwnerInterface
8
{
9
    /**
10
     * Raw response
11
     *
12
     * @var array
13
     */
14
    protected $response;
15
16
    /**
17
     * Creates new resource owner.
18
     *
19
     * @param array  $response
20
     */
21
    public function __construct(array $response = array())
22
    {
23
        $this->response = $response;
24
    }
25
26
    /**
27
     * Get resource owner id
28
     *
29
     * @return string|null
30
     */
31
    public function getId()
32
    {
33
        return $this->response['sub'] ?: null;
34
    }
35
36
    /**
37
     * Get resource owner email
38
     *
39
     * @return string|null
40
     */
41
    public function getEmail()
42
    {
43
        return $this->response['email'] ?: null;
44
    }
45
46
    /**
47
     * Get resource owner name
48
     *
49
     * @return string|null
50
     */
51
    public function getName()
52
    {
53
        return $this->response['name'] ?: null;
54
    }
55
56
    /**
57
     * Return all of the owner details available as an array.
58
     *
59
     * @return array
60
     */
61
    public function toArray()
62
    {
63
        return $this->response;
64
    }
65
}
66