AuthorizationMiddleware::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace DMT\Auth;
4
5
use Psr\Http\Message\RequestInterface;
6
7
/**
8
 * Class AuthorizationMiddleware
9
 *
10
 * @package DMT\Auth
11
 */
12
class AuthorizationMiddleware
13
{
14
    /**
15
     * @var AuthorizationInterface
16
     */
17
    protected $authorization;
18
19
    /**
20
     * AuthorizationMiddleware constructor.
21
     *
22
     * @param AuthorizationInterface $authorization
23
     */
24 4
    public function __construct(AuthorizationInterface $authorization)
25
    {
26 4
        $this->authorization = $authorization;
27 4
    }
28
29
    /**
30
     * Apply the authorization headers to the request.
31
     *
32
     * @param RequestInterface $request
33
     *
34
     * @return RequestInterface
35
     * @throws AuthorizationException
36
     */
37 4
    public function __invoke(RequestInterface $request)
38
    {
39 4
        return $this->authorization->handle($request);
40
    }
41
}
42