AbstractJwtAuth   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 20
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 TMV\OpenIdClient\AuthMethod;
6
7
use function array_merge;
8
use function http_build_query;
9
use Psr\Http\Message\RequestInterface;
10
use TMV\OpenIdClient\Client\ClientInterface as OpenIDClient;
11
12
abstract class AbstractJwtAuth implements AuthMethodInterface
13
{
14
    abstract protected function createAuthJwt(OpenIDClient $client, array $claims = []): string;
15
16 4
    public function createRequest(
17
        RequestInterface $request,
18
        OpenIDClient $client,
19
        array $claims
20
    ): RequestInterface {
21 4
        $clientId = $client->getMetadata()->getClientId();
22
23 4
        $claims = array_merge([
24 4
            'client_id' => $clientId,
25 4
            'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
26 4
            'client_assertion' => $this->createAuthJwt($client, $claims),
27 3
        ], $claims);
28
29 3
        $request->getBody()->write(http_build_query($claims));
30
31 3
        return $request;
32
    }
33
}
34