GumroadResourceOwner   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.48%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 101
ccs 19
cts 21
cp 0.9048
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getEmail() 0 4 1
A getName() 0 4 1
A getBio() 0 4 1
A getIdentities() 0 4 1
A getFacebookProfile() 0 4 1
A getTwitterHandle() 0 4 1
A getProfileUrl() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
/*
4
 * Gumroad OAuth2 Provider
5
 * (c) alofoxx
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Alofoxx\OAuth2\Client\Provider;
12
13
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
14
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
15
16
class GumroadResourceOwner implements ResourceOwnerInterface
17
{
18
    use ArrayAccessorTrait;
19
20
    /**
21
     * @var array
22
     */
23
    protected $response;
24
25 3
    public function __construct(array $response = [])
26
    {
27 3
        $this->response = $response;
28 3
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33 3
    public function getId()
34
    {
35 3
        return $this->getValueByKey($this->response, 'user_id');
36
    }
37
38
    /**
39
     * Returns email address of the resource owner
40
     *
41
     * @return string|null
42
     */
43 3
    public function getEmail()
44
    {
45 3
        return $this->getValueByKey($this->response, 'email');
46
    }
47
48
    /**
49
     * Returns full name of the resource owner
50
     *
51
     * @return string|null
52
     */
53 3
    public function getName()
54
    {
55 3
        return $this->getValueByKey($this->response, 'name');
56
    }
57
58
    /**
59
     * Returns Gumroad bio of the resource owner
60
     *
61
     * @return string|null
62
     */
63 3
    public function getBio()
64
    {
65 3
        return $this->getValueByKey($this->response, 'bio');
66
    }
67
68
    /**
69
     * Returns identities of the resource owner
70
     *
71
     * @see https://auth0.com/docs/user-profile/user-profile-structure
72
     * @return array|null
73
     */
74
    public function getIdentities()
75
    {
76
        return $this->getValueByKey($this->response, 'identities');
77
    }
78
79
    /**
80
     * Returns facebook profile of the resource owner
81
     *
82
     * @return string|null
83
     */
84 3
    public function getFacebookProfile()
85
    {
86 3
        return $this->getValueByKey($this->response, 'facebook_profile');
87
    }
88
89
    /**
90
     * Returns twitter handle of the resource owner
91
     *
92
     * @return string|null
93
     */
94 3
    public function getTwitterHandle()
95
    {
96 3
        return $this->getValueByKey($this->response, 'twitter_handle');
97
    }
98
99
    /**
100
     * Returns gumroad profile url of the resource owner
101
     *
102
     * @return string|null
103
     */
104 3
    public function getProfileUrl()
105
    {
106 3
        return $this->getValueByKey($this->response, 'url');
107
    }
108
109
    /**
110
     * @inheritdoc
111
     */
112 3
    public function toArray()
113
    {
114 3
        return $this->response;
115
    }
116
}
117