| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 63 | 
| Code Lines | 32 | 
| 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  | 
            ||
| 27 | public function store(Request $request)  | 
            ||
| 28 |     { | 
            ||
| 29 | // Validate the form  | 
            ||
| 30 | $request->validate([  | 
            ||
| 31 | 'custID' => 'required',  | 
            ||
| 32 | 'name' => 'required',  | 
            ||
| 33 | 'type' => 'required'  | 
            ||
| 34 | ]);  | 
            ||
| 35 | |||
| 36 |         $receiver = new FileReceiver('file', $request, HandlerFactory::classFromRequest($request)); | 
            ||
| 37 | |||
| 38 | // Verify that the upload is valid and being processed  | 
            ||
| 39 | if($receiver->isUploaded() === false)  | 
            ||
| 40 |         { | 
            ||
| 41 |             Log::error('Upload File Missing - '.$request->toArray()); | 
            ||
| 42 | throw new UploadMissingFileException();  | 
            ||
| 43 | }  | 
            ||
| 44 | |||
| 45 | // Receive and process the file  | 
            ||
| 46 | $save = $receiver->receive();  | 
            ||
| 47 | |||
| 48 | // See if the upload has finished  | 
            ||
| 49 | if($save->isFinished())  | 
            ||
| 50 |         { | 
            ||
| 51 | // Set file locationi and clean filename for duplicates  | 
            ||
| 52 |             $filePath = config('filesystems.paths.customers').DIRECTORY_SEPARATOR.$request->custID; | 
            ||
| 53 | $fileName = Files::cleanFileName($filePath, $request->file->getClientOriginalName());  | 
            ||
| 54 | |||
| 55 | // Store the file  | 
            ||
| 56 | $request->file->storeAs($filePath, $fileName);  | 
            ||
| 57 | |||
| 58 | // Put the file in the database  | 
            ||
| 59 | $file = Files::create(  | 
            ||
| 60 | [  | 
            ||
| 61 | 'file_name' => $fileName,  | 
            ||
| 62 | 'file_link' => $filePath.DIRECTORY_SEPARATOR  | 
            ||
| 63 | ]);  | 
            ||
| 64 | |||
| 65 | // Get information for system files table  | 
            ||
| 66 | $fileID = $file->file_id;  | 
            ||
| 67 | |||
| 68 | // Input the file into the customer files table  | 
            ||
| 69 | CustomerFiles::create([  | 
            ||
| 70 | 'file_id' => $fileID,  | 
            ||
| 71 | 'file_type_id' => $request->type,  | 
            ||
| 72 | 'cust_id' => $request->custID,  | 
            ||
| 73 | 'user_id' => Auth::user()->user_id,  | 
            ||
| 74 | 'name' => $request->name  | 
            ||
| 75 | ]);  | 
            ||
| 76 | |||
| 77 |             Log::debug('Route '.Route::currentRouteName().' visited by User ID-'.Auth::user()->user_id); | 
            ||
| 78 |             Log::debug('Submitted Data - ', $request->toArray()); | 
            ||
| 79 |             Log::info('File added for Customer ID-'.$request->custID.' by User ID-'.Auth::user()->user_id.'.  New File ID-'.$fileID); | 
            ||
| 80 | }  | 
            ||
| 81 | |||
| 82 | // Get the current progress  | 
            ||
| 83 | $handler = $save->handler();  | 
            ||
| 84 | |||
| 85 |         Log::debug('Route '.Route::currentRouteName().' visited by User ID-'.Auth::user()->user_id); | 
            ||
| 86 |         Log::debug('File being uploaded.  Percentage done - '.$handler->getPercentageDone()); | 
            ||
| 87 | return response()->json([  | 
            ||
| 88 | 'done' => $handler->getPercentageDone(),  | 
            ||
| 89 | 'status' => true  | 
            ||
| 90 | ]);  | 
            ||
| 126 |