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

Token::prepRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 4
nop 1
crap 2
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