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 | 28 |
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 | |||
19 | return null; |
||
20 | } |
||
21 | |||
22 | if ($value && is_file($value) && $value->isValid()) { |
||
23 | if ($previousFile) { |
||
24 | Storage::disk($this->getDisk())->delete($previousFile); |
||
25 | } |
||
26 | $fileName = $this->getFileName($value); |
||
27 | $value->storeAs($this->getPath(), $fileName, $this->getDisk()); |
||
28 | |||
29 | return $this->getPath().$fileName; |
||
30 | } |
||
31 | |||
32 | if (! $value && CrudPanelFacade::getRequest()->has($this->getNameForRequest()) && $previousFile) { |
||
33 | Storage::disk($this->getDisk())->delete($previousFile); |
||
34 | |||
35 | return null; |
||
36 | } |
||
37 | |||
38 | return $previousFile; |
||
39 | } |
||
83 |