AbstractJwtAuth   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createRequest() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\AuthMethod;
6
7
use function array_merge;
8
use Facile\OpenIDClient\Client\ClientInterface as OpenIDClient;
9
use function http_build_query;
10
use Psr\Http\Message\RequestInterface;
11
12
abstract class AbstractJwtAuth implements AuthMethodInterface
13
{
14
    /**
15
     * @param OpenIDClient $client
16
     * @param array<string, mixed> $claims
17
     *
18
     * @return string
19
     */
20
    abstract protected function createAuthJwt(OpenIDClient $client, array $claims = []): string;
21
22 4
    public function createRequest(
23
        RequestInterface $request,
24
        OpenIDClient $client,
25
        array $claims
26
    ): RequestInterface {
27 4
        $clientId = $client->getMetadata()->getClientId();
28
29 4
        $claims = array_merge([
30 4
            'client_id' => $clientId,
31 4
            'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
32 4
            'client_assertion' => $this->createAuthJwt($client, $claims),
33 3
        ], $claims);
34
35 3
        $request->getBody()->write(http_build_query($claims));
36
37 3
        return $request;
38
    }
39
}
40