| Conditions | 7 |
| Paths | 9 |
| Total Lines | 52 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 | Log::debug(' Visitor-Id = ' . $request->header('Visitor-Id')); |
||
| 46 | |||
| 47 | // Request Data: |
||
| 48 | if ($request->all()) { |
||
| 49 | $data = http_build_query($request->all(), '', ' ; '); |
||
| 50 | } else { |
||
| 51 | $data = 'N/A'; |
||
| 52 | } |
||
| 53 | Log::debug('Request Data: ' . $data); |
||
| 54 | |||
| 55 | // Authenticated User: |
||
| 56 | if ($request->user()) { |
||
| 57 | $user = 'ID: ' . $request->user()->id; |
||
| 58 | } else { |
||
| 59 | $user = 'N/A'; |
||
| 60 | } |
||
| 61 | Log::debug('Authenticated User: ' . $user); |
||
| 62 | |||
| 63 | // Response Content: |
||
| 64 | if ($response && method_exists($response, 'content')) { |
||
| 65 | Log::debug('Response: ' . substr($response->content(), 0, 700) . '...'); |
||
| 66 | } |
||
| 67 | |||
| 68 | Log::debug(''); |
||
| 69 | Log::debug(''); |
||
| 70 | |||
| 71 | } |
||
| 72 | |||
| 73 | // Perform action |
||
| 74 | |||
| 75 | return $response; |
||
| 76 | } |
||
| 77 | } |
||
| 78 |