Passed
Push — master ( 1d30f9...202808 )
by Peter
04:48
created

Token   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 25
dl 0
loc 132
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getExpiresAt() 0 3 1
A __construct() 0 12 1
A setApiClientId() 0 5 1
A getApiClientId() 0 3 1
A setRevokedAt() 0 5 1
A setAdminResources() 0 3 1
A getAdminResources() 0 3 1
A getId() 0 3 1
A getRevokedAt() 0 3 1
A setExpiresAt() 0 5 1
A setId() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Domain\Entities;
6
7
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
8
use DateTimeImmutable;
9
10
class Token implements IStringerEntity
11
{
12
    /** @var string */
13
    protected $id;
14
15
    /** @var string */
16
    protected $apiClientId;
17
18
    /** @var DateTimeImmutable|null */
19
    protected $expiresAt;
20
21
    /** @var DateTimeImmutable|null */
22
    protected $revokedAt;
23
24
    /** @var string[] */
25
    protected $adminResources;
26
27
    /**
28
     * Token constructor.
29
     *
30
     * @param string                 $id
31
     * @param string                 $apiClientId
32
     * @param DateTimeImmutable|null $expiresAt
33
     * @param DateTimeImmutable|null $revokedAt
34
     * @param string[]               $adminResources
35
     */
36
    public function __construct(
37
        string $id,
38
        string $apiClientId,
39
        ?DateTimeImmutable $expiresAt,
40
        ?DateTimeImmutable $revokedAt,
41
        array $adminResources = []
42
    ) {
43
        $this->id             = $id;
44
        $this->apiClientId    = $apiClientId;
45
        $this->expiresAt      = $expiresAt;
46
        $this->revokedAt      = $revokedAt;
47
        $this->adminResources = $adminResources;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getId()
54
    {
55
        return $this->id;
56
    }
57
58
    /**
59
     * @param string $id
60
     */
61
    public function setId($id)
62
    {
63
        $this->id = $id;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getApiClientId(): string
70
    {
71
        return $this->apiClientId;
72
    }
73
74
    /**
75
     * @param string $apiClientId
76
     */
77
    public function setApiClientId(string $apiClientId): Token
78
    {
79
        $this->apiClientId = $apiClientId;
80
81
        return $this;
82
    }
83
84
    /**
85
     * @return DateTimeImmutable|null
86
     */
87
    public function getExpiresAt(): ?DateTimeImmutable
88
    {
89
        return $this->expiresAt;
90
    }
91
92
    /**
93
     * @param DateTimeImmutable|null $expiresAt
94
     */
95
    public function setExpiresAt(?DateTimeImmutable $expiresAt): Token
96
    {
97
        $this->expiresAt = $expiresAt;
98
99
        return $this;
100
    }
101
102
    /**
103
     * @return DateTimeImmutable|null
104
     */
105
    public function getRevokedAt(): ?DateTimeImmutable
106
    {
107
        return $this->revokedAt;
108
    }
109
110
    /**
111
     * @param DateTimeImmutable|null $revokedAt
112
     */
113
    public function setRevokedAt(?DateTimeImmutable $revokedAt): Token
114
    {
115
        $this->revokedAt = $revokedAt;
116
117
        return $this;
118
    }
119
120
    /**
121
     * @return string[]
122
     */
123
    public function getAdminResources(): array
124
    {
125
        return $this->adminResources;
126
    }
127
128
    /**
129
     * @param string[] $adminResources
130
     */
131
    public function setAdminResources(array $adminResources): void
132
    {
133
        $this->adminResources = $adminResources;
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    public function __toString(): string
140
    {
141
        return $this->getUsername();
0 ignored issues
show
Bug introduced by
The method getUsername() does not exist on AbterPhp\Admin\Domain\Entities\Token. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

141
        return $this->/** @scrutinizer ignore-call */ getUsername();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
142
    }
143
}
144