Completed
Push — master ( 3e25b9...556647 )
by Márk
11s
created

AuthenticationPlugin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 25
ccs 7
cts 7
cp 1
rs 10

2 Methods

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