Passed
Push — master ( eeb9eb...608424 )
by Adam
50s queued 13s
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 15
    public function __construct(string $apiKey)
17
    {
18 15
        $this->apiKey = $apiKey;
19 15
    }
20
21 8
    public function __invoke(RequestInterface $request): RequestInterface
22
    {
23 8
        return $request->withHeader(
24 8
            'Authorization',
25
            sprintf(
26 8
                'Bearer %s',
27 8
                $this->apiKey
28
            )
29
        );
30
    }
31
}
32