Failed Conditions
Branch refactor/kernels (3a00e4)
by Atanas
01:41
created

HasRoutesTrait::route()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
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\Routing;
11
12
/**
13
 * Allow objects to have routes
14
 */
15
trait HasRoutesTrait {
16
	/**
17
	 * Array of registered routes
18
	 *
19
	 * @var RouteInterface[]
20
	 */
21
	protected $routes = [];
22
23
	/**
24
	 * Get routes.
25
	 *
26
	 * @return array<RouteInterface>
27
	 */
28
	public function getRoutes() {
29
		return $this->routes;
30
	}
31
32
	/**
33
	 * Set routes.
34
	 *
35
	 * @param  array<RouteInterface> $routes
36
	 * @return void
37
	 */
38
	public function setRoutes( $routes ) {
39
		$this->routes = $routes;
40
	}
41 1
42 1
	/**
43
	 * Add a route.
44
	 *
45
	 * @param  RouteInterface $route
46
	 * @return void
47
	 */
48
	public function addRoute( $route ) {
49
		$this->routes[] = $route;
50
	}
51
}
52