1 | <?php |
||
10 | final class DatabaseAccessTokenRepository implements AccessTokenRepositoryContract |
||
11 | { |
||
12 | /** |
||
13 | * The connection. |
||
14 | * |
||
15 | * @var ConnectionContract |
||
16 | */ |
||
17 | private $connection; |
||
18 | |||
19 | /** |
||
20 | * The temporary access token table. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | private $table; |
||
25 | |||
26 | /** |
||
27 | * The number of seconds a token should last. |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | private $expires; |
||
32 | |||
33 | /** |
||
34 | * DatabaseAccessTokenRepository constructor. |
||
35 | * |
||
36 | * @param ConnectionContract $connection |
||
37 | * @param string $table |
||
38 | * @param int $expires |
||
39 | */ |
||
40 | 11 | public function __construct(ConnectionContract $connection, $table, $expires) |
|
46 | |||
47 | /** |
||
48 | * Retrieve an access token from the storage. |
||
49 | * |
||
50 | * @param int $authenticatableId The unique identifier of the authenticatable who owns the access token. |
||
51 | * @param string $token The access code of the authenticatable. |
||
52 | * |
||
53 | * @return stdClass|array|bool |
||
54 | */ |
||
55 | 2 | public function retrieve($authenticatableId, $token) |
|
65 | |||
66 | /** |
||
67 | * Retrieve the first resource by the given attributes. |
||
68 | * |
||
69 | * @param array $queryParams The key - value pairs to match. |
||
70 | * @param array $attributes The attributes to be returned from the storage. |
||
71 | * |
||
72 | * @return stdClass|array|null |
||
73 | */ |
||
74 | 3 | public function retrieveByAttributes(array $queryParams, array $attributes = ['*']) |
|
90 | |||
91 | /** |
||
92 | * Store a new access token in the storage. |
||
93 | * |
||
94 | * @param int $authenticatableId The unique identifier of the authenticatable who owns the access token. |
||
95 | * @param string $token The access code generated for the authenticatable. |
||
96 | * @param string|null $expiresAt The expiration date of the access token. |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | 2 | public function store($authenticatableId, $token, $expiresAt = null) |
|
109 | |||
110 | /** |
||
111 | * Update the expire date of the given access token in the storage. |
||
112 | * |
||
113 | * @param int $authenticatableId The unique identifier of the authenticatable. |
||
114 | * @param string $token The encrypted access code to be updated. |
||
115 | * @param string $expires The new expiration date of the access token. |
||
116 | * |
||
117 | * @return bool |
||
118 | */ |
||
119 | 1 | public function update($authenticatableId, $token, $expires) |
|
125 | |||
126 | /** |
||
127 | * Delete a resource from the storage. |
||
128 | * |
||
129 | * @param int $authenticatableId The unique identifier of the authenticatable. |
||
130 | * @param string $token The code of the authenticatable. |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | 1 | public function delete($authenticatableId, $token) |
|
138 | |||
139 | /** |
||
140 | * Delete expired access tokens from the storage. |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | 1 | public function deleteExpired() |
|
148 | |||
149 | /** |
||
150 | * Get an access token payload. |
||
151 | * |
||
152 | * @param int $authenticatableId |
||
153 | * @param string $token |
||
154 | * @param string|null $expiresAt |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | 2 | private function getAccessTokenPayload($authenticatableId, $token, $expiresAt) |
|
171 | |||
172 | /** |
||
173 | * Determine if the token has expired. |
||
174 | * |
||
175 | * @param stdClass $token |
||
176 | * |
||
177 | * @return bool |
||
178 | */ |
||
179 | 4 | private function tokenExpired(stdClass $token) |
|
185 | |||
186 | /** |
||
187 | * Get the current UNIX timestamp. |
||
188 | * |
||
189 | * @return Carbon |
||
190 | */ |
||
191 | 7 | private function getNow() |
|
195 | |||
196 | /** |
||
197 | * Begin a new database query against the table. |
||
198 | * |
||
199 | * @return \Illuminate\Database\Query\Builder |
||
200 | */ |
||
201 | 10 | private function getTable() |
|
205 | |||
206 | /** |
||
207 | * Get the database connection instance. |
||
208 | * |
||
209 | * @return ConnectionContract |
||
210 | */ |
||
211 | 10 | private function getConnection() |
|
215 | } |
||
216 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.