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