Passed
Push — master ( 904589...078d26 )
by Thomas Mauro
02:52
created

AbstractJwtAuth::__construct()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 2
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TMV\OpenIdClient\AuthMethod;
6
7
use Psr\Http\Message\RequestInterface;
8
use TMV\OpenIdClient\ClientInterface as OpenIDClient;
9
10
abstract class AbstractJwtAuth implements AuthMethodInterface
11
{
12
    abstract protected function createAuthJwt(OpenIDClient $client, array $claims = []): string;
13
14 2
    public function createRequest(
15
        RequestInterface $request,
16
        OpenIDClient $client,
17
        array $claims
18
    ): RequestInterface {
19 2
        $clientId = $client->getMetadata()->getClientId();
20
21
        $claims = [
22 2
            'client_id' => $clientId,
23 2
            'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
24 2
            'client_assertion' => $this->createAuthJwt($client, $claims),
25
        ];
26
27 2
        $request->getBody()->write(\http_build_query($claims));
28
29 2
        return $request;
30
    }
31
}
32