BearerTokenMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 19
ccs 9
cts 9
cp 1
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 6
    public function __construct(string $apiKey)
17
    {
18 6
        $this->apiKey = $apiKey;
19 6
    }
20
21 1
    public function __invoke(RequestInterface $request): RequestInterface
22
    {
23 1
        return $request->withHeader(
24 1
            'Authorization',
25 1
            sprintf(
26 1
                'Bearer %s',
27 1
                $this->apiKey
28
            )
29
        );
30
    }
31
}
32