Completed
Push — b0.25.0 ( 08d9c9...6b8d05 )
by Sebastian
04:56
created

RouteCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 10 2
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * Linna Framework.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Router;
13
14
use Linna\TypedObjectArray;
15
16
/**
17
 * Route Collection
18
 */
19
class RouteCollection extends TypedObjectArray
20
{
21
    /**
22
     * Contructor.
23
     *
24
     * @param array $array
25
     */
26 76
    public function __construct(array $array = [])
27
    {
28 76
        parent::__construct(Route::class, $array);
29 75
    }
30
31
    /**
32
     * Return collection as array.
33
     *
34
     * @return array
35
     */
36 71
    public function toArray(): array
37
    {
38 71
        $array = $this->getArrayCopy();
39 71
        $tmp = [];
40
41 71
        foreach ($array as $route) {
42 71
            $tmp[] = $route->toArray();
43
        }
44
45 71
        return $tmp;
46
    }
47
}
48