Authorization   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A push() 0 4 1
A handle() 0 4 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