1 | <?php declare(strict_types=1); |
||
16 | class Service extends AbstractService implements IdentityService |
||
17 | { |
||
18 | 5 | public static function factory(ClientInterface $client): self |
|
22 | |||
23 | /** |
||
24 | * Authenticates credentials, giving back a token and a base URL for the service. |
||
25 | * |
||
26 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
27 | * |
||
28 | * @return array Returns a {@see Models\Token} as the first element, a string base URL as the second |
||
29 | */ |
||
30 | 6 | public function authenticate(array $options): array |
|
56 | 8 | ||
57 | /** |
||
58 | 8 | * Generates authentication token from cached token using `$token->export()` |
|
59 | * |
||
60 | * @param array $cachedToken {@see \OpenStack\Identity\v3\Models\Token::export} |
||
61 | * |
||
62 | * @return Models\Token |
||
63 | */ |
||
64 | public function generateTokenFromCache(array $cachedToken): Models\Token |
||
68 | |||
69 | 1 | /** |
|
70 | * Generates a new authentication token |
||
71 | 1 | * |
|
72 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
73 | * |
||
74 | * @return Models\Token |
||
75 | */ |
||
76 | public function generateToken(array $options): Models\Token |
||
80 | |||
81 | 2 | /** |
|
82 | * Retrieves a token object and populates its unique identifier object. This operation will not perform a GET or |
||
83 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
84 | 2 | * |
|
85 | 1 | * @param string $id The unique ID of the token to retrieve |
|
86 | 1 | * |
|
87 | 1 | * @return Models\Token |
|
88 | */ |
||
89 | public function getToken(string $id): Models\Token |
||
93 | |||
94 | /** |
||
95 | * Validates a token, identified by its ID, and returns TRUE if its valid, FALSE if not. |
||
96 | * |
||
97 | * @param string $id The unique ID of the token |
||
98 | * |
||
99 | 1 | * @return bool |
|
100 | 1 | */ |
|
101 | 1 | public function validateToken(string $id): bool |
|
110 | |||
111 | 1 | /** |
|
112 | * Revokes a token, identified by its ID. After this operation completes, users will not be able to use this token |
||
113 | 1 | * again for authentication. |
|
114 | * |
||
115 | * @param string $id The unique ID of the token |
||
116 | */ |
||
117 | public function revokeToken(string $id) |
||
121 | |||
122 | /** |
||
123 | * Creates a new service according to the provided options. |
||
124 | * |
||
125 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postServices} |
|
126 | * |
||
127 | 1 | * @return Models\Service |
|
128 | */ |
||
129 | public function createService(array $options): Models\Service |
||
133 | |||
134 | /** |
||
135 | * Returns a generator which will yield a collection of service objects. The elements which generators yield can be |
||
136 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
137 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
138 | 1 | * |
|
139 | * @param array $options {@see \OpenStack\Identity\v3\Api::getServices} |
||
140 | 1 | * |
|
141 | * @return \Generator |
||
142 | */ |
||
143 | public function listServices(array $options = []): \Generator |
||
147 | |||
148 | /** |
||
149 | * Retrieves a service object and populates its unique identifier object. This operation will not perform a GET or |
||
150 | 2 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
151 | * |
||
152 | 2 | * @param string $id The unique ID of the service |
|
153 | * |
||
154 | * @return Models\Service |
||
155 | */ |
||
156 | public function getService(string $id): Models\Service |
||
160 | |||
161 | /** |
||
162 | * Creates a new endpoint according to the provided options. |
||
163 | 1 | * |
|
164 | * @param array $options {@see \OpenStack\Identity\v3\Api::postEndpoints} |
||
165 | 1 | * |
|
166 | * @return Models\Endpoint |
||
167 | */ |
||
168 | public function createEndpoint(array $options): Models\Endpoint |
||
172 | |||
173 | /** |
||
174 | * Retrieves an endpoint object and populates its unique identifier object. This operation will not perform a GET or |
||
175 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
176 | * |
||
177 | 1 | * @param string $id The unique ID of the service |
|
178 | * |
||
179 | 1 | * @return Models\Endpoint |
|
180 | */ |
||
181 | public function getEndpoint(string $id): Models\Endpoint |
||
185 | |||
186 | /** |
||
187 | * Returns a generator which will yield a collection of endpoint objects. The elements which generators yield can be |
||
188 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
189 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
190 | * |
||
191 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getEndpoints} |
|
192 | * |
||
193 | * @return \Generator |
||
194 | */ |
||
195 | public function listEndpoints(array $options = []): \Generator |
||
199 | |||
200 | /** |
||
201 | * Creates a new domain according to the provided options. |
||
202 | * |
||
203 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postDomains} |
|
204 | * |
||
205 | 1 | * @return Models\Domain |
|
206 | */ |
||
207 | public function createDomain(array $options): Models\Domain |
||
211 | |||
212 | /** |
||
213 | * Returns a generator which will yield a collection of domain objects. The elements which generators yield can be |
||
214 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
215 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
216 | 1 | * |
|
217 | * @param array $options {@see \OpenStack\Identity\v3\Api::getDomains} |
||
218 | 1 | * |
|
219 | * @return \Generator |
||
220 | */ |
||
221 | public function listDomains(array $options = []): \Generator |
||
225 | |||
226 | /** |
||
227 | * Retrieves a domain object and populates its unique identifier object. This operation will not perform a GET or |
||
228 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
229 | * |
||
230 | 1 | * @param string $id The unique ID of the domain |
|
231 | * |
||
232 | * @return Models\Domain |
||
233 | */ |
||
234 | public function getDomain(string $id): Models\Domain |
||
238 | |||
239 | /** |
||
240 | * Creates a new project according to the provided options. |
||
241 | * |
||
242 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postProjects} |
|
243 | * |
||
244 | 1 | * @return Models\Project |
|
245 | */ |
||
246 | public function createProject(array $options): Models\Project |
||
250 | |||
251 | /** |
||
252 | * Returns a generator which will yield a collection of project objects. The elements which generators yield can be |
||
253 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
254 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
255 | 1 | * |
|
256 | * @param array $options {@see \OpenStack\Identity\v3\Api::getProjects} |
||
257 | 1 | * |
|
258 | * @return \Generator |
||
259 | */ |
||
260 | public function listProjects(array $options = []): \Generator |
||
264 | |||
265 | /** |
||
266 | * Retrieves a project object and populates its unique identifier object. This operation will not perform a GET or |
||
267 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
268 | * |
||
269 | 1 | * @param string $id The unique ID of the project |
|
270 | * |
||
271 | * @return Models\Project |
||
272 | */ |
||
273 | public function getProject(string $id): Models\Project |
||
277 | |||
278 | /** |
||
279 | * Creates a new user according to the provided options. |
||
280 | * |
||
281 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postUsers} |
|
282 | * |
||
283 | 1 | * @return Models\User |
|
284 | */ |
||
285 | public function createUser(array $options): Models\User |
||
289 | |||
290 | /** |
||
291 | * Returns a generator which will yield a collection of user objects. The elements which generators yield can be |
||
292 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
293 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
294 | 1 | * |
|
295 | * @param array $options {@see \OpenStack\Identity\v3\Api::getUsers} |
||
296 | 1 | * |
|
297 | * @return \Generator |
||
298 | */ |
||
299 | public function listUsers(array $options = []): \Generator |
||
303 | |||
304 | /** |
||
305 | * Retrieves a user object and populates its unique identifier object. This operation will not perform a GET or |
||
306 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
307 | * |
||
308 | 1 | * @param string $id The unique ID of the user |
|
309 | * |
||
310 | * @return Models\User |
||
311 | */ |
||
312 | public function getUser(string $id): Models\User |
||
316 | |||
317 | /** |
||
318 | * Creates a new group according to the provided options. |
||
319 | * |
||
320 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postGroups} |
|
321 | * |
||
322 | 1 | * @return Models\Group |
|
323 | */ |
||
324 | public function createGroup(array $options): Models\Group |
||
328 | |||
329 | /** |
||
330 | * Returns a generator which will yield a collection of group objects. The elements which generators yield can be |
||
331 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
332 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
333 | 1 | * |
|
334 | * @param array $options {@see \OpenStack\Identity\v3\Api::getGroups} |
||
335 | 1 | * |
|
336 | * @return \Generator |
||
337 | */ |
||
338 | public function listGroups(array $options = []): \Generator |
||
342 | |||
343 | /** |
||
344 | * Retrieves a group object and populates its unique identifier object. This operation will not perform a GET or |
||
345 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
346 | * |
||
347 | 1 | * @param string $id The unique ID of the group |
|
348 | * |
||
349 | * @return Models\Group |
||
350 | */ |
||
351 | public function getGroup($id): Models\Group |
||
355 | |||
356 | /** |
||
357 | 1 | * Creates a new credential according to the provided options. |
|
358 | * |
||
359 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postCredentials} |
|
360 | * |
||
361 | * @return Models\Credential |
||
362 | */ |
||
363 | public function createCredential(array $options): Models\Credential |
||
367 | |||
368 | /** |
||
369 | * Returns a generator which will yield a collection of credential objects. The elements which generators yield can |
||
370 | 1 | * be accessed using a foreach loop. Often the API will not return the full state of the resource in collections; |
|
371 | * you will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
372 | 1 | * |
|
373 | * @return \Generator |
||
374 | */ |
||
375 | public function listCredentials(): \Generator |
||
379 | |||
380 | /** |
||
381 | * Retrieves a credential object and populates its unique identifier object. This operation will not perform a GET |
||
382 | 1 | * or HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
383 | * |
||
384 | 1 | * @param string $id The unique ID of the credential |
|
385 | * |
||
386 | * @return Models\Credential |
||
387 | */ |
||
388 | public function getCredential(string $id): Models\Credential |
||
392 | |||
393 | /** |
||
394 | * Creates a new role according to the provided options. |
||
395 | * |
||
396 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postRoles} |
|
397 | * |
||
398 | 1 | * @return Models\Role |
|
399 | */ |
||
400 | public function createRole(array $options): Models\Role |
||
404 | |||
405 | /** |
||
406 | * Returns a generator which will yield a collection of role objects. The elements which generators yield can be |
||
407 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
408 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
409 | * |
||
410 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoles} |
|
411 | * |
||
412 | 1 | * @return \Generator |
|
413 | */ |
||
414 | public function listRoles(array $options = []): \Generator |
||
418 | |||
419 | /** |
||
420 | * Returns a generator which will yield a collection of role assignment objects. The elements which generators |
||
421 | * yield can be accessed using a foreach loop. Often the API will not return the full state of the resource in |
||
422 | 1 | * collections; you will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
423 | * |
||
424 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoleAssignments} |
|
425 | * |
||
426 | * @return \Generator |
||
427 | */ |
||
428 | public function listRoleAssignments(array $options = []): \Generator |
||
432 | |||
433 | /** |
||
434 | * Creates a new policy according to the provided options. |
||
435 | * |
||
436 | 1 | * @param array $options {@see \OpenStack\Identity\v3\Api::postPolicies} |
|
437 | * |
||
438 | 1 | * @return Models\Policy |
|
439 | */ |
||
440 | public function createPolicy(array $options): Models\Policy |
||
444 | |||
445 | /** |
||
446 | * Returns a generator which will yield a collection of policy objects. The elements which generators yield can be |
||
447 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
448 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
449 | 1 | * |
|
450 | * @param array $options {@see \OpenStack\Identity\v3\Api::getPolicies} |
||
451 | 1 | * |
|
452 | * @return \Generator |
||
453 | */ |
||
454 | public function listPolicies(array $options = []): \Generator |
||
458 | |||
459 | /** |
||
460 | * Retrieves a policy object and populates its unique identifier object. This operation will not perform a GET or |
||
461 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
462 | * |
||
463 | * @param string $id The unique ID of the policy |
||
464 | * |
||
465 | * @return Models\Policy |
||
466 | */ |
||
467 | public function getPolicy(string $id): Models\Policy |
||
471 | } |
||
472 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: