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

LocalizationKernelTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatchToRouter() 0 6 1
A replaceRouter() 0 12 3
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