| Conditions | 12 | 
| Paths | 32 | 
| Total Lines | 48 | 
| Code Lines | 37 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| 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  | 
            ||
| 21 | public function index(Request $request)  | 
            ||
| 22 |     { | 
            ||
| 23 | $this->singleLogsHandler();  | 
            ||
| 24 | $this->dailyLogsHandler();  | 
            ||
| 25 | |||
| 26 | $singleLogs = array_reverse($this->singleLogs);  | 
            ||
| 27 | $dailyLogs = array_reverse($this->dailyLogs);  | 
            ||
| 28 | |||
| 29 |         $logQuery = $request->input('log'); | 
            ||
| 30 | |||
| 31 |         if (isset($logQuery) && (! is_null($logQuery)) && array_key_exists($logQuery, $this->dailyLogs)) { | 
            ||
| 32 | $currentLog = $logQuery;  | 
            ||
| 33 |         } elseif (file_exists(storage_path('logs/laravel.log'))) { // me | 
            ||
| 34 | $currentLog = 'laravel';  | 
            ||
| 35 |         } elseif (count($dailyLogs) > 0) { // me | 
            ||
| 36 | $currentLog = array_key_first($dailyLogs); //me  | 
            ||
| 37 |         } else { | 
            ||
| 38 | $currentLog = null;  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 |         if ($currentLog === 'laravel') { | 
            ||
| 42 | $currentPage = LengthAwarePaginator::resolveCurrentPage();  | 
            ||
| 43 | $logsCollection = collect($singleLogs);  | 
            ||
| 44 | $perPage = 5;  | 
            ||
| 45 | $currentPageItems = $logsCollection->slice(($currentPage * $perPage) - $perPage, $perPage)->all();  | 
            ||
| 46 | $paginatedSingleLogs = new LengthAwarePaginator($currentPageItems , count($logsCollection), $perPage);  | 
            ||
| 47 | $paginatedSingleLogs->setPath($request->url());  | 
            ||
| 48 |         } elseif (isset($logQuery) && (! is_null($logQuery)) && array_key_exists($logQuery, $this->dailyLogs)) { | 
            ||
| 49 | $currentPage = LengthAwarePaginator::resolveCurrentPage();  | 
            ||
| 50 | $logsCollection = collect(array_reverse($dailyLogs[$logQuery]));  | 
            ||
| 51 | $perPage = 5;  | 
            ||
| 52 | $currentPageItems = $logsCollection->slice(($currentPage * $perPage) - $perPage, $perPage)->all();  | 
            ||
| 53 | $paginatedDailyLogs = new LengthAwarePaginator($currentPageItems , count($logsCollection), $perPage);  | 
            ||
| 54 |             $paginatedDailyLogs->setPath('logs?log=' . $currentLog); | 
            ||
| 55 |         } elseif (count($dailyLogs) > 0) { | 
            ||
| 56 | $currentPage = LengthAwarePaginator::resolveCurrentPage();  | 
            ||
| 57 | $logsCollection = collect(array_reverse($dailyLogs[$currentLog]));  | 
            ||
| 58 | $perPage = 5;  | 
            ||
| 59 | $currentPageItems = $logsCollection->slice(($currentPage * $perPage) - $perPage, $perPage)->all();  | 
            ||
| 60 | $paginatedDailyLogs = new LengthAwarePaginator($currentPageItems , count($logsCollection), $perPage);  | 
            ||
| 61 |             $paginatedDailyLogs->setPath('logs?log=' . $currentLog); | 
            ||
| 62 | }  | 
            ||
| 63 | |||
| 64 |         if (isset($paginatedDailyLogs)) { | 
            ||
| 65 |             return view('laralog::logs', compact('singleLogs', 'dailyLogs', 'currentLog', 'paginatedDailyLogs')); | 
            ||
| 66 | }  | 
            ||
| 67 | |||
| 68 |         return view('laralog::logs', compact('singleLogs', 'dailyLogs', 'currentLog', 'paginatedSingleLogs')); | 
            ||
| 69 | }  | 
            ||
| 133 |