PriorityMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getPriority() 0 2 1
A process() 0 2 1
1
<?php
2
/**
3
 * Class PriorityMiddleware
4
 *
5
 * @created      10.03.2019
6
 * @author       smiley <[email protected]>
7
 * @copyright    2019 smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\HTTP\Psr15;
12
13
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
14
use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface};
15
16
use const PHP_INT_MIN;
17
18
class PriorityMiddleware implements PriorityMiddlewareInterface{
19
20
	protected MiddlewareInterface $middleware;
21
	protected int                 $priority;
22
23
	/**
24
	 * PriorityMiddleware constructor.
25
	 */
26
	public function __construct(MiddlewareInterface $middleware, int $priority = null){
27
		$this->middleware = $middleware;
28
		$this->priority   = $priority ?? PHP_INT_MIN;
29
	}
30
31
	/**
32
	 * @inheritDoc
33
	 */
34
	public function process(ServerRequestInterface $request, RequestHandlerInterface $handler):ResponseInterface{
35
		return $this->middleware->process($request, $handler);
36
	}
37
38
	/**
39
	 * @inheritDoc
40
	 */
41
	public function getPriority():int{
42
		return $this->priority;
43
	}
44
45
}
46