Authorization::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polidog\Esa\Client;
6
7
use GuzzleHttp\HandlerStack;
8
use GuzzleHttp\Middleware;
9
use Psr\Http\Message\MessageInterface;
10
use Psr\Http\Message\RequestInterface;
11
12
class Authorization
13
{
14
    /**
15
     * @var string
16
     */
17
    private $accessToken;
18
19
    public function __construct(string $accessToken)
20
    {
21 4
        $this->accessToken = $accessToken;
22
    }
23 4
24 4
    public function push(HandlerStack $stack): void
25
    {
26
        $stack->push(Middleware::mapRequest([$this, 'handle']));
27
    }
28
29 3
    public function handle(RequestInterface $request): MessageInterface
30
    {
31 3
        return $request->withHeader('Authorization', 'Bearer '.$this->accessToken);
32 3
    }
33
}
34