Completed
Pull Request — master (#110)
by ARCANEDEV
06:21
created

Router::getActiveMiddlewares()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
1
<?php namespace Arcanedev\Localization\Routing;
2
3
use Closure;
4
5
/**
6
 * Class     Router
7
 *
8
 * @package  Arcanedev\Localization\Routing
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @mixin \Illuminate\Routing\Router
12
 */
13
class Router
14
{
15
    /* -----------------------------------------------------------------
16
     |  Route Methods
17
     | -----------------------------------------------------------------
18
     */
19
20
    /**
21
     * Create a route group with shared attributes.
22
     *
23
     * @return \Closure
24
     */
25
    public function localizedGroup()
26
    {
27 252
        return function(Closure $callback, array $attributes = []) {
28 252
            $activeMiddleware = array_keys(array_filter(
29 252
                config('localization.route.middleware', [])
30
            ));
31
32 252
            $attributes = array_merge($attributes, [
33 252
                'prefix'     => localization()->setLocale(),
34 252
                'middleware' => $activeMiddleware,
35
            ]);
36
37 252
            $this->group(array_filter($attributes), $callback);
0 ignored issues
show
Bug introduced by
The method group() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38 252
        };
39
    }
40
41
    /**
42
     * Register a new translated GET route with the router.
43
     *
44
     * @return \Closure|\Illuminate\Routing\Route
45
     */
46
    public function transGet()
47
    {
48 252
        return function($trans, $action) {
49 252
            return $this->get(
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50 252
                localization()->transRoute($trans), $action
51
            );
52 252
        };
53
    }
54
55
    /**
56
     * Register a new translated POST route with the router.
57
     *
58
     * @return \Closure|\Illuminate\Routing\Route
59
     */
60
    public function transPost()
61
    {
62 252
        return function($trans, $action) {
63 252
            return $this->post(
0 ignored issues
show
Bug introduced by
The method post() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64 252
                localization()->transRoute($trans), $action
65
            );
66 252
        };
67
    }
68
69
    /**
70
     * Register a new translated PUT route with the router.
71
     *
72
     * @return \Closure|\Illuminate\Routing\Route
73
     */
74
    public function transPut()
75
    {
76 252
        return function($trans, $action) {
77 252
            return $this->put(
0 ignored issues
show
Bug introduced by
The method put() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78 252
                localization()->transRoute($trans), $action
79
            );
80 252
        };
81
    }
82
83
    /**
84
     * Register a new translated PATCH route with the router.
85
     *
86
     * @return \Closure|\Illuminate\Routing\Route
87
     */
88
    public function transPatch()
89
    {
90 252
        return function($trans, $action) {
91 252
            return $this->patch(
0 ignored issues
show
Bug introduced by
The method patch() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92 252
                localization()->transRoute($trans), $action
93
            );
94 252
        };
95
    }
96
97
    /**
98
     * Register a new translated DELETE route with the router.
99
     *
100
     * @return \Closure|\Illuminate\Routing\Route
101
     */
102
    public function transDelete()
103
    {
104 252
        return function($trans, $action) {
105 252
            return $this->delete(
0 ignored issues
show
Bug introduced by
The method delete() does not exist on Arcanedev\Localization\Routing\Router. Did you maybe mean transDelete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
106 252
                localization()->transRoute($trans), $action
107
            );
108 252
        };
109
    }
110
111
    /**
112
     * Register a new translated OPTIONS route with the router.
113
     *
114
     * @return \Closure|\Illuminate\Routing\Route
115
     */
116
    public function transOptions()
117
    {
118 252
        return function($trans, $action) {
119 252
            return $this->options(
0 ignored issues
show
Bug introduced by
The method options() does not exist on Arcanedev\Localization\Routing\Router. Did you maybe mean transOptions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
120 252
                localization()->transRoute($trans), $action
121
            );
122 252
        };
123
    }
124
125
    /**
126
     * Register a new translated any route with the router.
127
     *
128
     * @return \Closure|\Illuminate\Routing\Route
129
     */
130
    public function transAny()
131
    {
132 252
        return function($trans, $action) {
133 252
            return $this->any(
0 ignored issues
show
Bug introduced by
The method any() does not seem to exist on object<Arcanedev\Localization\Routing\Router>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
134 252
                localization()->transRoute($trans), $action
135
            );
136 252
        };
137
    }
138
}
139