Completed
Push — add-pleio-mod ( 6d68a5 )
by
unknown
28:07
created

ResourceOwner::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
namespace ModPleio;
3
4
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
5
use League\OAuth2\Client\Provider\GenericResourceOwner;
6
7
class ResourceOwner extends GenericResourceOwner {
8
    use ArrayAccessorTrait;
9
10
    protected $response;
11
12
    public function __construct(array $response = array()) {
13
        $this->response = $response;
14
    }
15
16
    public function getGuid() {
17
        return $this->getValueByKey($this->response, "guid");
18
    }
19
20
    public function getUsername() {
21
        return $this->getValueByKey($this->response, "username");
22
    }
23
24
    public function getEmail() {
25
        return $this->getValueByKey($this->response, "email");
26
    }
27
28
    public function getIcon() {
29
        return $this->getValueByKey($this->response, "icon");
30
    }
31
32
    public function getLanguage() {
33
        return $this->getValueByKey($this->response, "language");
34
    }
35
36
    public function getName() {
37
        return $this->getValueByKey($this->response, "name");
38
    }
39
40
    public function getUrl() {
41
        return $this->getValueByKey($this->response, "url");
42
    }
43
44
    public function getProfile() {
45
        if (is_array($this->getValueByKey($this->response, "profile"))) {
46
            return $this->getValueByKey($this->response, "profile");
47
        }
48
49
        return [];
50
    }
51
52
    public function isAdmin() {
53
        return $this->getValueByKey($this->response, "isAdmin");
54
    }
55
56
    public function toArray() {
57
        return $this->response;
58
    }
59
60
}