Completed
Branch feature/router-decorator (f7629b)
by Frédéric
02:12
created

RouteCollection::refresh()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 13
ccs 9
cts 9
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace CaribouFute\LocaleRoute\Routing;
4
5
use Illuminate\Routing\RouteCollection as IlluminateRouteCollection;
6
7
class RouteCollection extends IlluminateRouteCollection
8
{
9 25
    public function hydrate(IlluminateRouteCollection $coll)
10
    {
11 25
        $this->routes = $coll->routes;
12 25
        $this->allRoutes = $coll->allRoutes;
13 25
        $this->nameList = $coll->nameList;
14 25
        $this->actionList = $coll->actionList;
15 25
    }
16
17 24
    public function refresh()
18
    {
19 24
        $routes = $this->getRoutes();
20
21 24
        $this->routes = [];
22 24
        $this->allRoutes = [];
23 24
        $this->nameList = [];
24 24
        $this->actionList = [];
25
26 24
        foreach ($routes as $route) {
27 24
            $this->add($route);
28
        }
29 24
    }
30
}
31