Completed
Push — master ( 481c33...0c5dca )
by Nate
04:03
created

Token   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A prepRequest() 0 7 1
1
<?php
2
3
namespace Flipbox\Relay\HubSpot\Middleware\Authorization;
4
5
use Flipbox\Relay\Middleware\AbstractMiddleware;
6
use Psr\Http\Message\RequestInterface;
7
use Psr\Http\Message\ResponseInterface;
8
9
class Token extends AbstractMiddleware
10
{
11
12
    /**
13
     * @var string|\League\OAuth2\Client\Token\AccessToken
14
     */
15
    public $token;
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next = null)
21
    {
22
        return $next($this->prepRequest($request), $response);
23
    }
24
25
    /**
26
     * @param RequestInterface $request
27
     * @return RequestInterface
28
     */
29
    private function prepRequest(RequestInterface $request)
30
    {
31
        return $request->withHeader(
32
            "Authorization",
33
            sprintf("Bearer %s", $this->token)
34
        );
35
    }
36
}
37