Test Failed
Push — master ( 802c16...59dfb3 )
by Adam
44s queued 12s
created

BearerTokenMiddleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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