| Conditions | 11 |
| Paths | 13 |
| Total Lines | 59 |
| Code Lines | 34 |
| 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 |
||
| 21 | protected function handleStyles(string $id, Model|string $model, bool $standalone = false): void |
||
| 22 | { |
||
| 23 | switch ($this->type) { |
||
| 24 | case LaruploadFileType::IMAGE: |
||
| 25 | foreach ($this->imageStyles as $name => $style) { |
||
| 26 | $path = $this->getBasePath($id, $name); |
||
|
|
|||
| 27 | $saveTo = $path . '/' . FixExceptionNamesAction::make($this->output['name'], $name)->run(); |
||
| 28 | |||
| 29 | Storage::disk($this->disk)->makeDirectory($path); |
||
| 30 | $this->img($this->file)->resize($saveTo, $style); |
||
| 31 | } |
||
| 32 | |||
| 33 | break; |
||
| 34 | |||
| 35 | case LaruploadFileType::VIDEO: |
||
| 36 | if ($this->ffmpegQueue) { |
||
| 37 | if ($this->driverIsNotLocal()) { |
||
| 38 | $this->uploadOriginalFile($id, $this->localDisk); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($model instanceof Model) { |
||
| 42 | $this->initializeFFMpegQueue( |
||
| 43 | $model->id, $model->getMorphClass(), $standalone |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | else { |
||
| 47 | $this->initializeFFMpegQueue( |
||
| 48 | $id, $model, $standalone |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | else { |
||
| 53 | $this->handleVideoStyles($id); |
||
| 54 | } |
||
| 55 | |||
| 56 | break; |
||
| 57 | |||
| 58 | case LaruploadFileType::AUDIO: |
||
| 59 | if ($this->ffmpegQueue) { |
||
| 60 | if ($this->driverIsNotLocal()) { |
||
| 61 | $this->uploadOriginalFile($id, $this->localDisk); |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($model instanceof Model) { |
||
| 65 | $this->initializeFFMpegQueue( |
||
| 66 | $model->id, $model->getMorphClass(), $standalone |
||
| 67 | ); |
||
| 68 | } |
||
| 69 | else { |
||
| 70 | $this->initializeFFMpegQueue( |
||
| 71 | $id, $model, $standalone |
||
| 72 | ); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | else { |
||
| 76 | $this->handleAudioStyles($id); |
||
| 77 | } |
||
| 78 | |||
| 79 | break; |
||
| 80 | } |
||
| 181 |