ChasterAppResourceOwner::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/** @noinspection PhpIllegalPsrClassPathInspection */
4
5
namespace Austomos\OAuth2\Client\Provider;
6
7
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
8
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
9
10
/**
11
 * Data of auth/profile endpoint API request
12
 * @link https://api.chaster.app/api/#/Profile/AuthMeController_me
13
 */
14
class ChasterAppResourceOwner implements ResourceOwnerInterface
15
{
16
    use ArrayAccessorTrait;
17
18
    /**
19
     * Data of the user profile
20
     * @var array
21
     */
22
    protected array $response;
23
24
    public function __construct(array $response = [])
25
    {
26
        $this->response = $response;
27
    }
28
29
    /**
30
     * Provide data using array key of profile data
31
     * @param string $name
32
     *
33
     * @return mixed
34
     *
35
     * @noinspection MagicMethodsValidityInspection
36
     */
37
    public function __get(string $name)
38
    {
39
        return $this->getValueByKey($this->response, $name);
40
    }
41
42
    /**
43
     * Get profile email
44
     * @return string
45
     */
46
    public function getEmail(): string
47
    {
48
        return $this->getValueByKey($this->response, 'email', '');
49
    }
50
51
    /**
52
     * Get profile _id
53
     * @return string
54
     */
55
    public function getId(): string
56
    {
57
        return $this->getValueByKey($this->response, '_id', '');
58
    }
59
60
    /**
61
     * Get profile Username
62
     * @return string
63
     */
64
    public function getUsername(): string
65
    {
66
        return $this->getValueByKey($this->response, 'username', '');
67
    }
68
69
    /**
70
     * Return profile array
71
     * @return array
72
     */
73
    public function toArray(): array
74
    {
75
        return $this->response;
76
    }
77
}
78