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