Cancelled
Push — master ( 9b9d7f...d61628 )
by Sebastian
10:59
created

RouteCollection::__construct()   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 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * Linna Framework.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2017, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Http;
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 6
    public function __construct(array $array = [])
27
    {
28 6
        parent::__construct(Route::class, $array);
29 5
    }
30
    
31
    /**
32
     * Return collection as array.
33
     * 
34
     * @return array
35
     */
36 1
    public function toArray() : array
37
    {
38 1
        $array = $this->getArrayCopy();
39 1
        $tmp = [];
40
        
41 1
        foreach ($array as $route) {
42 1
            $tmp[] = $route->toArray();
43
        }
44
        
45 1
        return $tmp;
46
    }
47
}