Test Failed
Push — master ( 3fe005...bfd1fd )
by Antonio Carlos
09:02
created

Routing::getRouter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PragmaRX\Health\Support\Traits;
4
5
trait Routing
6
{
7
    /**
8
     * @param $route
9
     * @param null $name
10
     */
11 2
    protected function registerRoute($route, $name = null)
12
    {
13 2
        $action = isset($route['controller'])
14
            ? "{$route['controller']}@{$route['action']}"
15 2
            : $route['action'];
16
17 2
        $router = $this->getRouter()->get($route['uri'], [
18 2
            'as' => $name ?: $route['name'],
19 2
            'uses' => $action,
20
        ]);
21
22 2
        if (isset($route['middleware'])) {
23 2
            $router->middleware($route['middleware']);
24
        }
25 2
    }
26
27
    /**
28
     * Get the current router.
29
     *
30
     * @return mixed
31
     */
32 2
    protected function getRouter()
33
    {
34 2
        return app()->router;
35
    }
36
}
37