We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 | 
| Paths | 24 | 
| Total Lines | 35 | 
| Code Lines | 17 | 
| 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  | 
            ||
| 17 | public function uploadFile(Model $entry, $value = null)  | 
            ||
| 18 |     { | 
            ||
| 19 |         $filesToDelete = CRUD::getRequest()->get('clear_'.$this->getName()); | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 20 | |||
| 21 | $value = $value ?? CRUD::getRequest()->file($this->getName());  | 
            ||
| 22 | |||
| 23 | $previousFiles = $entry->getOriginal($this->getName()) ?? [];  | 
            ||
| 24 | |||
| 25 |         if (! is_array($previousFiles) && is_string($previousFiles)) { | 
            ||
| 26 | $previousFiles = json_decode($previousFiles, true);  | 
            ||
| 27 | }  | 
            ||
| 28 | |||
| 29 |         if ($filesToDelete) { | 
            ||
| 30 |             foreach ($previousFiles as $previousFile) { | 
            ||
| 31 |                 if (in_array($previousFile, $filesToDelete)) { | 
            ||
| 32 | Storage::disk($this->getDisk())->delete($previousFile);  | 
            ||
| 33 | |||
| 34 |                     $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { | 
            ||
| 35 | return $value != $previousFile;  | 
            ||
| 36 | });  | 
            ||
| 37 | }  | 
            ||
| 38 | }  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 |         foreach ($value ?? [] as $file) { | 
            ||
| 42 |             if ($file && is_file($file)) { | 
            ||
| 43 | $fileName = $this->getFileName($file);  | 
            ||
| 44 | |||
| 45 | $file->storeAs($this->getPath(), $fileName, $this->getDisk());  | 
            ||
| 46 | |||
| 47 | $previousFiles[] = $this->getPath().$fileName;  | 
            ||
| 48 | }  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 | return isset($entry->getCasts()[$this->getName()]) ? $previousFiles : json_encode($previousFiles);  | 
            ||
| 52 | }  | 
            ||
| 83 |