Passed
Push — master ( 8fd0b9...c0bcb1 )
by Adam
54s queued 12s
created

BearerTokenMiddleware::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0046

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
ccs 5
cts 6
cp 0.8333
rs 10
cc 1
nc 1
nop 1
crap 1.0046
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Beachcasts\Airtable\Middleware;
6
7
use Psr\Http\Message\RequestInterface;
8
9
class BearerTokenMiddleware
10
{
11
    /**
12
     * @var string
13
     */
14
    private $apiKey;
15
16 14
    public function __construct(string $apiKey)
17
    {
18 14
        $this->apiKey = $apiKey;
19 14
    }
20
21 7
    public function __invoke(RequestInterface $request): RequestInterface
22
    {
23 7
        return $request->withHeader(
24 7
            'Authorization',
25
            sprintf(
26 7
                'Bearer %s',
27 7
                $this->apiKey
28
            )
29
        );
30
    }
31
}
32