CloudConvertResourceOwner::getEmail()   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
declare(strict_types=1);
4
5
namespace Osavchenko\OAuth2\Client\Provider;
6
7
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
8
9
class CloudConvertResourceOwner implements ResourceOwnerInterface
10
{
11
    private int $id;
12
    private string $username;
13
    private string $email;
14
    private int $credits;
15
    private array $links;
16
    private \DateTime $createdAt;
17
18
    public function __construct(array $response)
19
    {
20
        $data = $response['data'];
21
22
        $this->id = $data['id'];
23
        $this->username = $data['username'];
24
        $this->email = $data['email'];
25
        $this->credits = $data['credits'];
26
        $this->links = $data['links'];
27
        $this->createdAt = new \DateTime($data['created_at']);
28
    }
29
30
    public function getId(): int
31
    {
32
        return $this->id;
33
    }
34
35
    public function getUsername(): string
36
    {
37
        return $this->username;
38
    }
39
40
    public function getEmail(): string
41
    {
42
        return $this->email;
43
    }
44
45
    public function getCredits(): int
46
    {
47
        return $this->credits;
48
    }
49
50
    /**
51
     * @return string[]
52
     */
53
    public function getLinks(): array
54
    {
55
        return $this->links;
56
    }
57
58
    public function getCreatedAt(): \DateTime
59
    {
60
        return $this->createdAt;
61
    }
62
63
    /**
64
     * @return mixed[]
65
     */
66
    public function toArray(): array
67
    {
68
        return [
69
            'id' => $this->id,
70
            'username' => $this->username,
71
            'email' => $this->email,
72
            'credits' => $this->credits,
73
            'links' => $this->links,
74
            'created_at' => $this->createdAt->format('Y-m-d H:i:s'),
75
        ];
76
    }
77
}
78