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

BearerTokenMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 7 1
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