Completed
Pull Request — master (#14)
by Márk
14:10 queued 11:56
created

AuthenticationPlugin::handleRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Http\Client\Common\Plugin;
4
5
use Http\Client\Common\Plugin;
6
use Http\Message\Authentication;
7
use Psr\Http\Message\RequestInterface;
8
9
/**
10
 * Send an authenticated request.
11
 *
12
 * @author Joel Wurtz <[email protected]>
13
 */
14
final class AuthenticationPlugin implements Plugin
15
{
16
    /**
17
     * @var Authentication An authentication system
18
     */
19
    private $authentication;
20
21
    /**
22
     * @param Authentication $authentication
23
     */
24 3
    public function __construct(Authentication $authentication)
25
    {
26 3
        $this->authentication = $authentication;
27 3
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function handleRequest(RequestInterface $request, callable $next, callable $first)
33 1
    {
34 1
        $request = $this->authentication->authenticate($request);
35
36 1
        return $next($request);
37
    }
38
}
39