We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 15 |
| 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 |
||
| 11 | public function uploadFiles(Model $entry, $value = null) |
||
| 12 | { |
||
| 13 | $value = $value ?? CrudPanelFacade::getRequest()->file($this->getName()); |
||
|
|
|||
| 14 | $previousFile = $this->getPreviousFiles($entry); |
||
| 15 | |||
| 16 | if($value === false && $previousFile) { |
||
| 17 | Storage::disk($this->getDisk())->delete($previousFile); |
||
| 18 | return null; |
||
| 19 | } |
||
| 20 | |||
| 21 | if ($value && is_file($value) && $value->isValid()) { |
||
| 22 | if ($previousFile) { |
||
| 23 | Storage::disk($this->getDisk())->delete($previousFile); |
||
| 24 | } |
||
| 25 | $fileName = $this->getFileName($value); |
||
| 26 | $value->storeAs($this->getPath(), $fileName, $this->getDisk()); |
||
| 27 | |||
| 28 | return $this->getPath().$fileName; |
||
| 29 | } |
||
| 30 | |||
| 31 | if (! $value && CrudPanelFacade::getRequest()->has($this->getNameForRequest()) && $previousFile) { |
||
| 32 | Storage::disk($this->getDisk())->delete($previousFile); |
||
| 33 | |||
| 34 | return null; |
||
| 35 | } |
||
| 36 | return $previousFile; |
||
| 37 | } |
||
| 81 |