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

ResourceOwner   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
ccs 0
cts 36
cp 0
wmc 12
lcom 1
cbo 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getGuid() 0 3 1
A getUsername() 0 3 1
A getEmail() 0 3 1
A getIcon() 0 3 1
A getLanguage() 0 3 1
A getName() 0 3 1
A getUrl() 0 3 1
A getProfile() 0 7 2
A isAdmin() 0 3 1
A toArray() 0 3 1
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
}