ApereoCasResourceOwner   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 94
rs 10
wmc 11

7 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A getEmail() 0 3 2
A __construct() 0 3 1
A getUrl() 0 5 2
A getName() 0 3 2
A getId() 0 3 2
A setDomain() 0 5 1
1
<?php
2
3
namespace Ajtak\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
7
8
class ApereoCasResourceOwner implements ResourceOwnerInterface
9
{
10
    use ArrayAccessorTrait;
11
12
    /**
13
     * Domain
14
     *
15
     * @var string
16
     */
17
    protected $domain;
18
19
    /**
20
     * Raw response
21
     *
22
     * @var array
23
     */
24
    protected $response;
25
26
    /**
27
     * Creates new resource owner.
28
     *
29
     * @param array  $response
30
     */
31
    public function __construct(array $response = array())
32
    {
33
        $this->response = $response;
34
    }
35
36
    /**
37
     * Get resource owner id
38
     *
39
     * @return string|null
40
     */
41
    public function getId()
42
    {
43
        return \array_key_exists('sub', $this->response) ? $this->response['sub'] : null;
44
    }
45
46
    /**
47
     * Get resource owner email
48
     *
49
     * @return string|null
50
     */
51
    public function getEmail()
52
    {
53
        return \array_key_exists('email', $this->response) ? $this->response['email'] : null;
54
    }
55
56
    /**
57
     * Get resource owner name
58
     *
59
     * @return string|null
60
     */
61
    public function getName()
62
    {
63
        return \array_key_exists('name', $this->response) ? $this->response['name'] : null;
64
    }
65
66
    /**
67
     * Get resource owner url
68
     *
69
     * @return string|null
70
     */
71
    public function getUrl()
72
    {
73
        $urlParts = array_filter([$this->domain]);
74
75
        return count($urlParts) ? implode('/', $urlParts) : null;
76
    }
77
78
79
    /**
80
     * Set resource owner domain
81
     *
82
     * @param string $domain
83
     *
84
     * @return ApereoCasResourceOwner
85
     */
86
    public function setDomain($domain)
87
    {
88
        $this->domain = $domain;
89
90
        return $this;
91
    }
92
93
94
    /**
95
     * Return all of the owner details available as an array.
96
     *
97
     * @return array
98
     */
99
    public function toArray()
100
    {
101
        return $this->response;
102
    }
103
}
104