Passed
Push — master ( 87e3ec...f2e62f )
by Alexander
03:40 queued 01:16
created

RouteCollector::getItems()   A

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Router;
6
7
final class RouteCollector implements RouteCollectorInterface
8
{
9
    /**
10
     * @var Group[]|Route[]
11
     */
12
    private array $items = [];
13
    private array $middlewareDefinitions = [];
14
15 3
    public function addRoute(Route $route): RouteCollectorInterface
16
    {
17 3
        $this->items[] = $route;
18 3
        return $this;
19
    }
20
21 14
    public function addGroup(Group $group): RouteCollectorInterface
22
    {
23 14
        $this->items[] = $group;
24 14
        return $this;
25
    }
26
27 2
    public function middleware($middlewareDefinition): RouteCollectorInterface
28
    {
29 2
        array_unshift($this->middlewareDefinitions, $middlewareDefinition);
30 2
        return $this;
31
    }
32
33 1
    public function prependMiddleware($middlewareDefinition): RouteCollectorInterface
34
    {
35 1
        $this->middlewareDefinitions[] = $middlewareDefinition;
36 1
        return $this;
37
    }
38
39 15
    public function getItems(): array
40
    {
41 15
        return $this->items;
42
    }
43
44 14
    public function getMiddlewareDefinitions(): array
45
    {
46 14
        return $this->middlewareDefinitions;
47
    }
48
}
49