Failed Conditions
Branch refactor/kernels (cc9370)
by Atanas
02:23
created

WordPressHttpKernel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 64
ccs 0
cts 6
cp 0
c 0
b 0
f 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A handle() 0 2 1
A bootstrap() 0 5 1
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2018 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
namespace WPEmerge\Kernels;
11
12
use WPEmerge\Requests\RequestInterface;
13
use WPEmerge\Routing\Router;
14
15
/**
16
 * Describes how a request is handled.
17
 */
18
class WordPressHttpKernel implements HttpKernel {
19
	/**
20
	 * Router.
21
	 *
22
	 * @var Router|null
23
	 */
24
	protected $router = null;
25
26
	/**
27
	 * Middleware available to the application.
28
	 * TODO: implement.
29
	 *
30
	 * @var array<string, string>
31
	 */
32
	protected $middleware = [];
33
34
	/**
35
	 * Middleware groups.
36
	 * TODO: implement.
37
	 *
38
	 * @var array<string, array>
39
	 */
40
	protected $middleware_groups = [];
41
42
	/**
43
	 * Global middleware that will be applied to all routes.
44
	 *
45
	 * @var array
46
	 */
47
	protected $global_middleware = [];
48
49
	/**
50
	 * Middleware sorted in order of execution.
51
	 *
52
	 * @var array<string>
53
	 */
54
	protected $middleware_priority = [];
55
56
	/**
57
	 * Constructor.
58
	 *
59
	 * @codeCoverageIgnore
60
	 * @param Router $router
61
	 */
62
	public function __construct( $router ) {
63
		$this->router = $router;
64
	}
65
66
	/**
67
	 * {@inheritDoc}
68
	 */
69
	public function bootstrap() {
70
		$this->router->setMiddleware( $this->middleware );
0 ignored issues
show
Bug introduced by
The method setMiddleware() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
		$this->router->/** @scrutinizer ignore-call */ 
71
                 setMiddleware( $this->middleware );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
		$this->router->setMiddlewareGroups( $this->middleware_groups );
72
		$this->router->setGlobalMiddleware( $this->global_middleware );
73
		$this->router->setMiddlewarePriority( $this->middleware_priority );
74
	}
75
76
	/**
77
	 * {@inheritDoc}
78
	 * @codeCoverageIgnore
79
	 */
80
	public function handle( RequestInterface $request, $view ) {
81
		return $this->router->execute( $request, $view );
82
	}
83
}
84