Conditions | 4 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
36 | public function map(Router $router) |
||
|
|||
37 | { |
||
38 | Route::group(['namespace' => $this->namespace], function () { |
||
39 | |||
40 | /* |
||
41 | * Special routes |
||
42 | */ |
||
43 | Route::group(['middleware' => 'web'], function () { |
||
44 | Route::demoAccess('/demo'); |
||
45 | |||
46 | Route::get('coming-soon', function () { |
||
47 | return view('temp/index'); |
||
48 | }); |
||
49 | }); |
||
50 | |||
51 | /* |
||
52 | * Back site |
||
53 | */ |
||
54 | Route::group(['namespace' => 'Back', 'middleware' => 'web', 'prefix' => 'blender'], function () { |
||
55 | Auth::routes(); |
||
56 | |||
57 | Route::group(['middleware' => 'auth'], function () { |
||
58 | require base_path('routes/back.php'); |
||
59 | }); |
||
60 | }); |
||
61 | |||
62 | /* |
||
63 | * Frontsite |
||
64 | */ |
||
65 | |||
66 | Route::group(['namespace' => 'Front'], function () { |
||
67 | Route::group(['namespace' => 'Api', 'middleware' => 'api', 'prefix' => 'api'], function () { |
||
68 | require base_path('routes/frontApi.php'); |
||
69 | }); |
||
70 | |||
71 | Route::group(['middleware' => ['web', 'demoMode', 'rememberLocale']], function () { |
||
72 | $multiLingual = count(config('app.locales')) > 1; |
||
73 | |||
74 | Route::group($multiLingual ? ['prefix' => locale()] : [], function () { |
||
75 | try { |
||
76 | Auth::routes(); |
||
77 | require base_path('routes/front.php'); |
||
78 | } catch (Exception $exception) { |
||
79 | logger()->warning("Front routes weren't included because {$exception->getMessage()}."); |
||
80 | } |
||
81 | }); |
||
82 | |||
83 | if ($multiLingual) { |
||
84 | Route::get('/', function () { |
||
85 | return redirect(locale()); |
||
86 | }); |
||
87 | } |
||
88 | }); |
||
89 | }); |
||
90 | }); |
||
91 | } |
||
92 | } |
||
93 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.