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 |
|
53 | |||
54 | public function generateTokenFromCache(array $cache): Models\Token |
||
58 | 8 | ||
59 | /** |
||
60 | * Generates a new authentication token |
||
61 | * |
||
62 | * @param array $options {@see \OpenStack\Identity\v3\Api::postTokens} |
||
63 | * |
||
64 | * @return Models\Token |
||
65 | */ |
||
66 | public function generateToken(array $options): Models\Token |
||
70 | |||
71 | 1 | /** |
|
72 | * Retrieves a token object and populates its unique identifier object. This operation will not perform a GET or |
||
73 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
||
74 | * |
||
75 | * @param string $id The unique ID of the token to retrieve |
||
76 | * |
||
77 | * @return Models\Token |
||
78 | */ |
||
79 | public function getToken(string $id): Models\Token |
||
83 | |||
84 | 2 | /** |
|
85 | 1 | * Validates a token, identified by its ID, and returns TRUE if its valid, FALSE if not. |
|
86 | 1 | * |
|
87 | 1 | * @param string $id The unique ID of the token |
|
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | public function validateToken(string $id): bool |
||
100 | 1 | ||
101 | 1 | /** |
|
102 | 1 | * Revokes a token, identified by its ID. After this operation completes, users will not be able to use this token |
|
103 | * again for authentication. |
||
104 | * |
||
105 | * @param string $id The unique ID of the token |
||
106 | */ |
||
107 | public function revokeToken(string $id) |
||
111 | 1 | ||
112 | /** |
||
113 | 1 | * Creates a new service according to the provided options. |
|
114 | * |
||
115 | * @param array $options {@see \OpenStack\Identity\v3\Api::postServices} |
||
116 | * |
||
117 | * @return Models\Service |
||
118 | */ |
||
119 | public function createService(array $options): Models\Service |
||
123 | |||
124 | /** |
||
125 | 1 | * Returns a generator which will yield a collection of service objects. The elements which generators yield can be |
|
126 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
127 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
128 | * |
||
129 | * @param array $options {@see \OpenStack\Identity\v3\Api::getServices} |
||
130 | * |
||
131 | * @return \Generator |
||
132 | */ |
||
133 | public function listServices(array $options = []): \Generator |
||
137 | |||
138 | 1 | /** |
|
139 | * Retrieves a service object and populates its unique identifier object. This operation will not perform a GET or |
||
140 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
141 | * |
||
142 | * @param string $id The unique ID of the service |
||
143 | * |
||
144 | * @return Models\Service |
||
145 | */ |
||
146 | public function getService(string $id): Models\Service |
||
150 | 2 | ||
151 | /** |
||
152 | 2 | * Creates a new endpoint according to the provided options. |
|
153 | * |
||
154 | * @param array $options {@see \OpenStack\Identity\v3\Api::postEndpoints} |
||
155 | * |
||
156 | * @return Models\Endpoint |
||
157 | */ |
||
158 | public function createEndpoint(array $options): Models\Endpoint |
||
162 | |||
163 | 1 | /** |
|
164 | * Retrieves an endpoint object and populates its unique identifier object. This operation will not perform a GET or |
||
165 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
166 | * |
||
167 | * @param string $id The unique ID of the service |
||
168 | * |
||
169 | * @return Models\Endpoint |
||
170 | */ |
||
171 | public function getEndpoint(string $id): Models\Endpoint |
||
175 | |||
176 | /** |
||
177 | 1 | * Returns a generator which will yield a collection of endpoint objects. The elements which generators yield can be |
|
178 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
179 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
180 | * |
||
181 | * @param array $options {@see \OpenStack\Identity\v3\Api::getEndpoints} |
||
182 | * |
||
183 | * @return \Generator |
||
184 | */ |
||
185 | public function listEndpoints(array $options = []): \Generator |
||
189 | 1 | ||
190 | /** |
||
191 | 1 | * Creates a new domain according to the provided options. |
|
192 | * |
||
193 | * @param array $options {@see \OpenStack\Identity\v3\Api::postDomains} |
||
194 | * |
||
195 | * @return Models\Domain |
||
196 | */ |
||
197 | public function createDomain(array $options): Models\Domain |
||
201 | |||
202 | /** |
||
203 | 1 | * Returns a generator which will yield a collection of domain objects. The elements which generators yield can be |
|
204 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
205 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
206 | * |
||
207 | * @param array $options {@see \OpenStack\Identity\v3\Api::getDomains} |
||
208 | * |
||
209 | * @return \Generator |
||
210 | */ |
||
211 | public function listDomains(array $options = []): \Generator |
||
215 | |||
216 | 1 | /** |
|
217 | * Retrieves a domain object and populates its unique identifier object. This operation will not perform a GET or |
||
218 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
219 | * |
||
220 | * @param string $id The unique ID of the domain |
||
221 | * |
||
222 | * @return Models\Domain |
||
223 | */ |
||
224 | public function getDomain(string $id): Models\Domain |
||
228 | 1 | ||
229 | /** |
||
230 | 1 | * Creates a new project according to the provided options. |
|
231 | * |
||
232 | * @param array $options {@see \OpenStack\Identity\v3\Api::postProjects} |
||
233 | * |
||
234 | * @return Models\Project |
||
235 | */ |
||
236 | public function createProject(array $options): Models\Project |
||
240 | |||
241 | /** |
||
242 | 1 | * Returns a generator which will yield a collection of project objects. The elements which generators yield can be |
|
243 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
244 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
245 | * |
||
246 | * @param array $options {@see \OpenStack\Identity\v3\Api::getProjects} |
||
247 | * |
||
248 | * @return \Generator |
||
249 | */ |
||
250 | public function listProjects(array $options = []): \Generator |
||
254 | |||
255 | 1 | /** |
|
256 | * Retrieves a project object and populates its unique identifier object. This operation will not perform a GET or |
||
257 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
258 | * |
||
259 | * @param string $id The unique ID of the project |
||
260 | * |
||
261 | * @return Models\Project |
||
262 | */ |
||
263 | public function getProject(string $id): Models\Project |
||
267 | 1 | ||
268 | /** |
||
269 | 1 | * Creates a new user according to the provided options. |
|
270 | * |
||
271 | * @param array $options {@see \OpenStack\Identity\v3\Api::postUsers} |
||
272 | * |
||
273 | * @return Models\User |
||
274 | */ |
||
275 | public function createUser(array $options): Models\User |
||
279 | |||
280 | /** |
||
281 | 1 | * Returns a generator which will yield a collection of user objects. The elements which generators yield can be |
|
282 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
283 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
284 | * |
||
285 | * @param array $options {@see \OpenStack\Identity\v3\Api::getUsers} |
||
286 | * |
||
287 | * @return \Generator |
||
288 | */ |
||
289 | public function listUsers(array $options = []): \Generator |
||
293 | |||
294 | 1 | /** |
|
295 | * Retrieves a user object and populates its unique identifier object. This operation will not perform a GET or |
||
296 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
297 | * |
||
298 | * @param string $id The unique ID of the user |
||
299 | * |
||
300 | * @return Models\User |
||
301 | */ |
||
302 | public function getUser(string $id): Models\User |
||
306 | 1 | ||
307 | /** |
||
308 | 1 | * Creates a new group according to the provided options. |
|
309 | * |
||
310 | * @param array $options {@see \OpenStack\Identity\v3\Api::postGroups} |
||
311 | * |
||
312 | * @return Models\Group |
||
313 | */ |
||
314 | public function createGroup(array $options): Models\Group |
||
318 | |||
319 | /** |
||
320 | 1 | * Returns a generator which will yield a collection of group objects. The elements which generators yield can be |
|
321 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
322 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
323 | * |
||
324 | * @param array $options {@see \OpenStack\Identity\v3\Api::getGroups} |
||
325 | * |
||
326 | * @return \Generator |
||
327 | */ |
||
328 | public function listGroups(array $options = []): \Generator |
||
332 | |||
333 | 1 | /** |
|
334 | * Retrieves a group object and populates its unique identifier object. This operation will not perform a GET or |
||
335 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
336 | * |
||
337 | * @param string $id The unique ID of the group |
||
338 | * |
||
339 | * @return Models\Group |
||
340 | */ |
||
341 | public function getGroup($id): Models\Group |
||
345 | 1 | ||
346 | /** |
||
347 | 1 | * Creates a new credential according to the provided options. |
|
348 | * |
||
349 | * @param array $options {@see \OpenStack\Identity\v3\Api::postCredentials} |
||
350 | * |
||
351 | * @return Models\Credential |
||
352 | */ |
||
353 | public function createCredential(array $options): Models\Credential |
||
357 | 1 | ||
358 | /** |
||
359 | 1 | * Returns a generator which will yield a collection of credential objects. The elements which generators yield can |
|
360 | * be accessed using a foreach loop. Often the API will not return the full state of the resource in collections; |
||
361 | * you will need to use retrieve() to pull in the full state of the remote resource from the API. |
||
362 | * |
||
363 | * @return \Generator |
||
364 | */ |
||
365 | public function listCredentials(): \Generator |
||
369 | |||
370 | 1 | /** |
|
371 | * Retrieves a credential object and populates its unique identifier object. This operation will not perform a GET |
||
372 | 1 | * or HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
373 | * |
||
374 | * @param string $id The unique ID of the credential |
||
375 | * |
||
376 | * @return Models\Credential |
||
377 | */ |
||
378 | public function getCredential(string $id): Models\Credential |
||
382 | 1 | ||
383 | /** |
||
384 | 1 | * Creates a new role according to the provided options. |
|
385 | * |
||
386 | * @param array $options {@see \OpenStack\Identity\v3\Api::postRoles} |
||
387 | * |
||
388 | * @return Models\Role |
||
389 | */ |
||
390 | public function createRole(array $options): Models\Role |
||
394 | |||
395 | /** |
||
396 | 1 | * Returns a generator which will yield a collection of role objects. The elements which generators yield can be |
|
397 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
398 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
399 | * |
||
400 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoles} |
||
401 | * |
||
402 | * @return \Generator |
||
403 | */ |
||
404 | public function listRoles(array $options = []): \Generator |
||
408 | |||
409 | /** |
||
410 | 1 | * Returns a generator which will yield a collection of role assignment objects. The elements which generators |
|
411 | * yield can be accessed using a foreach loop. Often the API will not return the full state of the resource in |
||
412 | 1 | * collections; you will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
413 | * |
||
414 | * @param array $options {@see \OpenStack\Identity\v3\Api::getRoleAssignments} |
||
415 | * |
||
416 | * @return \Generator |
||
417 | */ |
||
418 | public function listRoleAssignments(array $options = []): \Generator |
||
422 | 1 | ||
423 | /** |
||
424 | 1 | * Creates a new policy according to the provided options. |
|
425 | * |
||
426 | * @param array $options {@see \OpenStack\Identity\v3\Api::postPolicies} |
||
427 | * |
||
428 | * @return Models\Policy |
||
429 | */ |
||
430 | public function createPolicy(array $options): Models\Policy |
||
434 | |||
435 | /** |
||
436 | 1 | * Returns a generator which will yield a collection of policy objects. The elements which generators yield can be |
|
437 | * accessed using a foreach loop. Often the API will not return the full state of the resource in collections; you |
||
438 | 1 | * will need to use retrieve() to pull in the full state of the remote resource from the API. |
|
439 | * |
||
440 | * @param array $options {@see \OpenStack\Identity\v3\Api::getPolicies} |
||
441 | * |
||
442 | * @return \Generator |
||
443 | */ |
||
444 | public function listPolicies(array $options = []): \Generator |
||
448 | |||
449 | 1 | /** |
|
450 | * Retrieves a policy object and populates its unique identifier object. This operation will not perform a GET or |
||
451 | 1 | * HEAD request by default; you will need to call retrieve() if you want to pull in remote state from the API. |
|
452 | * |
||
453 | * @param string $id The unique ID of the policy |
||
454 | * |
||
455 | * @return Models\Policy |
||
456 | */ |
||
457 | public function getPolicy(string $id): Models\Policy |
||
461 | } |
||
462 |
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: