Completed
Push — master ( bc0bfa...b3fff2 )
by ARCANEDEV
10s
created

LocalizationKernelTrait::dispatchToRouter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 4
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
1
<?php namespace Arcanedev\Localization\Traits;
2
3
/**
4
 * Class     LocalizationKernelTrait
5
 *
6
 * @package  Arcanedev\Localization\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 *
9
 * @property  \Illuminate\Foundation\Application      app
10
 * @property  \Arcanedev\Localization\Routing\Router  router
11
 * @property  array                                   middlewareGroups
12
 * @property  array                                   routeMiddleware
13
 */
14
trait LocalizationKernelTrait
15
{
16
    /**
17
     * Get the route dispatcher callback.
18
     *
19
     * @return \Closure
20
     */
21 15
    protected function dispatchToRouter()
22
    {
23 15
        $this->replaceRouter();
24
25 15
        return parent::dispatchToRouter();
26
    }
27
28
    /**
29
     * Replace the illuminate router with the localization router.
30
     */
31 15
    protected function replaceRouter()
32
    {
33 15
        $this->router = $this->app->make('router');
34
35 15
        foreach ($this->middlewareGroups as $key => $middleware) {
36 15
            $this->router->middlewareGroup($key, $middleware);
37 5
        }
38
39 15
        foreach ($this->routeMiddleware as $key => $middleware) {
40 15
            $this->router->aliasMiddleware($key, $middleware);
41 5
        }
42 15
    }
43
}
44