SePayResourceOwner   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getLastName() 0 3 1
A getAvatarUrl() 0 3 1
A __construct() 0 3 1
A getFirstName() 0 3 1
A getEmail() 0 3 1
A toArray() 0 3 1
A getId() 0 3 1
A getName() 0 6 1
A getPhone() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Datlechin\OAuth2\Client\Provider;
6
7
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
8
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
9
10
class SePayResourceOwner implements ResourceOwnerInterface
11
{
12
    use ArrayAccessorTrait;
13
14
    protected array $data;
15
16
    public function __construct(array $response)
17
    {
18
        $this->data = $response['data'];
19
    }
20
21
    public function getId(): int
22
    {
23
        return $this->getValueByKey($this->data, 'id');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueByKey($this->data, 'id') could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
24
    }
25
26
    public function getEmail(): string
27
    {
28
        return $this->getValueByKey($this->data, 'email');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueByKey($this->data, 'email') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
29
    }
30
31
    public function getName(): string
32
    {
33
        return sprintf(
34
            '%s %s',
35
            $this->getFirstName(),
36
            $this->getLastName()
37
        );
38
    }
39
40
    public function getFirstName(): string
41
    {
42
        return $this->getValueByKey($this->data, 'first_name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...is->data, 'first_name') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
45
    public function getLastName(): string
46
    {
47
        return $this->getValueByKey($this->data, 'last_name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...his->data, 'last_name') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
48
    }
49
50
    public function getAvatarUrl(): string
51
    {
52
        return $this->getValueByKey($this->data, 'avatar');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...($this->data, 'avatar') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
53
    }
54
55
    public function getPhone(): string
56
    {
57
        return $this->getValueByKey($this->data, 'phone');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueByKey($this->data, 'phone') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
58
    }
59
60
    public function toArray(): array
61
    {
62
        return $this->data;
63
    }
64
}
65