Completed
Push — master ( 5f96b8...92f9dc )
by Graham
03:54
created

BuzzOAuthMiddleware::handleResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the DigitalOceanV2 library.
5
 *
6
 * (c) Antoine Corcy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DigitalOceanV2\Adapter;
13
14
use Buzz\Middleware\MiddlewareInterface;
15
use Psr\Http\Message\RequestInterface;
16
use Psr\Http\Message\ResponseInterface;
17
18
/**
19
 * @author Antoine Corcy <[email protected]>
20
 * @author Graham Campbell <[email protected]>
21
 */
22
class BuzzOAuthMiddleware implements MiddlewareInterface
23
{
24
    /**
25
     * @var string
26
     */
27
    protected $token;
28
29
    /**
30
     * @param string $token
31
     */
32
    public function __construct($token)
33
    {
34
        $this->token = $token;
35
    }
36
37
    public function handleRequest(RequestInterface $request, callable $next)
38
    {
39
        return $next($request->withHeader('Authorization', sprintf('Bearer %s', $this->token)));
40
    }
41
42
    public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next)
43
    {
44
        return $next($request, $response);
45
    }
46
}
47