Total Complexity | 11 |
Total Lines | 94 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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() |
||
102 | } |
||
103 | } |
||
104 |