| Conditions | 13 |
| Paths | 8 |
| Total Lines | 37 |
| 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 |
||
| 131 | protected function prepareStylePath(string $style): ?string |
||
| 132 | { |
||
| 133 | $staticStyles = [ |
||
| 134 | Larupload::ORIGINAL_FOLDER, |
||
| 135 | Larupload::COVER_FOLDER, |
||
| 136 | Larupload::STREAM_FOLDER |
||
| 137 | ]; |
||
| 138 | |||
| 139 | if (isset($this->id) and (in_array($style, $staticStyles) or array_key_exists($style, $this->imageStyles) or array_key_exists($style, $this->videoStyles) or array_key_exists($style, $this->audioStyles))) { |
||
| 140 | $name = $style == Larupload::COVER_FOLDER |
||
| 141 | ? $this->output['cover'] |
||
| 142 | : $this->output['name']; |
||
| 143 | |||
| 144 | $type = $this->output['type'] |
||
| 145 | ? LaruploadFileType::from($this->output['type']) |
||
| 146 | : null; |
||
| 147 | |||
| 148 | if ($name and $style == Larupload::STREAM_FOLDER) { |
||
| 149 | if ($type === LaruploadFileType::VIDEO) { |
||
| 150 | $name = pathinfo($name, PATHINFO_FILENAME) . '.m3u8'; |
||
| 151 | $path = $this->getBasePath($this->id, $style); |
||
| 152 | |||
| 153 | return "$path/$name"; |
||
| 154 | } |
||
| 155 | |||
| 156 | return null; |
||
| 157 | } |
||
| 158 | else if ($name and $this->styleHasFile($style)) { |
||
| 159 | |||
| 160 | $name = FixExceptionNamesAction::make($name, $style, $this->getStyle($style))->run(); |
||
| 161 | $path = $this->getBasePath($this->id, $style); |
||
| 162 | |||
| 163 | return "$path/$name"; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | |||
| 167 | return null; |
||
| 168 | } |
||
| 170 |