Conditions | 12 |
Paths | 16 |
Total Lines | 33 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
13 | public function handle($request, Closure $next) |
||
14 | { |
||
15 | if (Request::is('js/*.js') || Request::is('api/login')) { |
||
16 | return $next($request); |
||
17 | } |
||
18 | |||
19 | $set_data = new SettingRepository(); |
||
20 | $settings = $set_data->getCacheSetting(); |
||
21 | |||
22 | // сайт отключен на обновление / диагностику |
||
23 | if (isset($settings['disable_site']) && $settings['disable_site']) { |
||
24 | if (Gate::allows('admin-only', auth()->user())) { |
||
25 | return $next($request); |
||
26 | } |
||
27 | abort(521); |
||
28 | } |
||
29 | |||
30 | // Доступ к сайту только для зарегистрированных пользователей |
||
31 | if (isset($settings['registered_allow']) && $settings['registered_allow']) { |
||
32 | if (Auth::check()) { |
||
33 | return $next($request); |
||
34 | } |
||
35 | abort(403); |
||
36 | } |
||
37 | |||
38 | // Запрет всех роутов регистрации; |
||
39 | if (isset($settings['enable_register']) && !$settings['enable_register']) { |
||
40 | if (Request::is('api/register')) { |
||
41 | abort(403); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return $next($request); |
||
46 | } |
||
48 |