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

Routing   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerRoute() 0 15 4
A getRouter() 0 4 1
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