1 | <?php |
||
21 | trait AccessTokenTrait |
||
22 | { |
||
23 | /** |
||
24 | * @var CryptKey |
||
25 | */ |
||
26 | private $privateKey; |
||
27 | |||
28 | /** |
||
29 | * Set the private key used to encrypt this access token. |
||
30 | */ |
||
31 | 29 | public function setPrivateKey(CryptKey $privateKey) |
|
35 | |||
36 | /** |
||
37 | * Generate a JWT from the access token |
||
38 | * |
||
39 | * @param CryptKey $privateKey |
||
40 | * |
||
41 | * @return Token |
||
42 | */ |
||
43 | 9 | private function convertToJWT(CryptKey $privateKey) |
|
56 | |||
57 | /** |
||
58 | * Generate a string representation from the access token |
||
59 | */ |
||
60 | 9 | public function __toString() |
|
64 | |||
65 | /** |
||
66 | * @return ClientEntityInterface |
||
67 | */ |
||
68 | abstract public function getClient(); |
||
69 | |||
70 | /** |
||
71 | * @return DateTimeImmutable |
||
72 | */ |
||
73 | abstract public function getExpiryDateTime(); |
||
74 | |||
75 | /** |
||
76 | * @return string|int |
||
77 | */ |
||
78 | abstract public function getUserIdentifier(); |
||
79 | |||
80 | /** |
||
81 | * @return ScopeEntityInterface[] |
||
82 | */ |
||
83 | abstract public function getScopes(); |
||
84 | } |
||
85 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.