Passed
Pull Request — master (#34)
by Anatoly
02:02
created

RouteCollection::getIterator()   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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router;
13
14
/**
15
 * RouteCollection
16
 */
17
class RouteCollection implements RouteCollectionInterface
18
{
19
20
    /**
21
     * The collection routes
22
     *
23
     * @var RouteInterface[]
24
     */
25
    private $routes;
26
27
    /**
28
     * Constructor of the class
29
     *
30
     * @param RouteInterface ...$routes
31
     */
32 45
    public function __construct(RouteInterface ...$routes)
33
    {
34 45
        $this->routes = $routes;
35 45
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 34
    public function add(RouteInterface ...$routes) : void
41
    {
42 34
        foreach ($routes as $route) {
43 34
            $this->routes[] = $route;
44
        }
45 34
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50 16
    public function all() : array
51
    {
52 16
        return $this->routes;
53
    }
54
}
55