Passed
Push — master ( 69906d...00f66f )
by Alexander
01:16
created

Group::addRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Yiisoft\Router;
4
5
use Psr\Http\Server\MiddlewareInterface;
6
7
class Group
8
{
9
    /**
10
     * @var Route[]
11
     */
12
    private $routes;
13
14
    /**
15
     * @var string
16
     */
17
    private $prefix;
18
19
    /**
20
     * @var GroupMiddlewareInterface|null
21
     */
22
    private $middleware;
23
24 3
    public function __construct(string $prefix, GroupMiddlewareInterface $middleware = null)
25
    {
26 3
        $this->prefix = $prefix;
27 3
        $this->middleware = $middleware;
28
    }
29
30 1
    public function addRoute(Route $route): self
31
    {
32 1
        $this->routes[] = $route;
33 1
        return $this;
34
    }
35
36
    /**
37
     * @return Route[]
38
     */
39 1
    public function getRoutes(): iterable
40
    {
41 1
        return $this->routes;
42
    }
43
44 1
    public function getPrefix(): string
45
    {
46 1
        return $this->prefix;
47
    }
48
49 1
    public function getMiddleware(): ?GroupMiddlewareInterface
50
    {
51 1
        return $this->middleware;
52
    }
53
}
54