Conditions | 7 |
Paths | 9 |
Total Lines | 51 |
Code Lines | 25 |
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 |
||
25 | public function handle(Request $request, Closure $next) |
||
26 | { |
||
27 | |||
28 | $response = $next($request); |
||
29 | |||
30 | if (App::environment() != 'testing' && Config::get('app.debug') === true) { |
||
31 | |||
32 | Log::debug(''); |
||
33 | Log::debug(''); |
||
34 | Log::debug('REQUEST START------------------------------------------------------'); |
||
35 | |||
36 | // Endpoint URL: |
||
37 | Log::debug('URL: ' . $request->getMethod() . ' ' . $request->fullUrl()); |
||
38 | |||
39 | // Request Device IP: |
||
40 | Log::debug('IP: ' . $request->ip()); |
||
41 | |||
42 | // Request Headers: |
||
43 | Log::debug('App Headers: '); |
||
44 | Log::debug(' Authorization = ' . substr($request->header('Authorization'), 0, 80) . '...'); |
||
45 | |||
46 | // Request Data: |
||
47 | if ($request->all()) { |
||
48 | $data = http_build_query($request->all(), '', ' ; '); |
||
49 | } else { |
||
50 | $data = 'N/A'; |
||
51 | } |
||
52 | Log::debug('Request Data: ' . $data); |
||
53 | |||
54 | // Authenticated User: |
||
55 | if ($request->user()) { |
||
56 | $user = 'ID: ' . $request->user()->id; |
||
57 | } else { |
||
58 | $user = 'N/A'; |
||
59 | } |
||
60 | Log::debug('Authenticated User: ' . $user); |
||
61 | |||
62 | // Response Content: |
||
63 | if ($response && method_exists($response, 'content')) { |
||
64 | Log::debug('Response: ' . substr($response->content(), 0, 700) . '...'); |
||
65 | } |
||
66 | |||
67 | Log::debug(''); |
||
68 | Log::debug(''); |
||
69 | |||
70 | } |
||
71 | |||
72 | // Perform action |
||
73 | |||
74 | return $response; |
||
75 | } |
||
76 | } |
||
77 |