| Conditions | 5 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 6.6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | function get_endpoint_uri(OpenIDClient $client, string $endpointMetadata): string |
||
| 19 | { |
||
| 20 | 1 | $authMethod = $client->getMetadata()->get($endpointMetadata . '_auth_method'); |
|
| 21 | |||
| 22 | 1 | $endpoint = null; |
|
| 23 | |||
| 24 | 1 | if (null !== $authMethod && false !== strpos($authMethod, 'tls_client_auth')) { |
|
| 25 | $endpoint = $client->getIssuer() |
||
| 26 | ->getMetadata() |
||
| 27 | ->getMtlsEndpointAliases()['token_endpoint'] ?? null; |
||
| 28 | } |
||
| 29 | |||
| 30 | 1 | $endpoint = $endpoint ?: $client->getIssuer()->getMetadata()->get($endpointMetadata); |
|
| 31 | |||
| 32 | 1 | if (! is_string($endpoint)) { |
|
| 33 | throw new RuntimeException('Unable to retrieve the token endpoint'); |
||
| 34 | } |
||
| 35 | |||
| 36 | 1 | return $endpoint; |
|
| 37 | } |
||
| 38 |