Conditions | 12 |
Paths | 8 |
Total Lines | 36 |
Code Lines | 22 |
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 |
||
92 | protected function prepareStylePath(string $style): ?string |
||
93 | { |
||
94 | $staticStyles = [ |
||
95 | Larupload::ORIGINAL_FOLDER, |
||
96 | Larupload::COVER_FOLDER, |
||
97 | Larupload::STREAM_FOLDER |
||
98 | ]; |
||
99 | |||
100 | if (isset($this->id) and (in_array($style, $staticStyles) or array_key_exists($style, $this->imageStyles) or array_key_exists($style, $this->videoStyles))) { |
||
101 | $name = $style == Larupload::COVER_FOLDER |
||
102 | ? $this->output['cover'] |
||
103 | : $this->output['name']; |
||
104 | |||
105 | $type = $this->output['type'] |
||
106 | ? LaruploadFileType::from($this->output['type']) |
||
107 | : null; |
||
108 | |||
109 | if ($name and $style == Larupload::STREAM_FOLDER) { |
||
110 | if ($type === LaruploadFileType::VIDEO) { |
||
111 | $name = pathinfo($name, PATHINFO_FILENAME) . '.m3u8'; |
||
112 | $path = $this->getBasePath($this->id, $style); |
||
113 | |||
114 | return "$path/$name"; |
||
115 | } |
||
116 | |||
117 | return null; |
||
118 | } |
||
119 | else if ($name and $this->styleHasFile($style)) { |
||
120 | $name = FixExceptionNamesAction::make($name, $style)->run(); |
||
121 | $path = $this->getBasePath($this->id, $style); |
||
122 | |||
123 | return "$path/$name"; |
||
124 | } |
||
125 | } |
||
126 | |||
127 | return null; |
||
128 | } |
||
130 |