| 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 |
||
| 82 | protected function prepareStylePath(string $style): ?string |
||
| 83 | { |
||
| 84 | $staticStyles = [ |
||
| 85 | Larupload::ORIGINAL_FOLDER, |
||
| 86 | Larupload::COVER_FOLDER, |
||
| 87 | Larupload::STREAM_FOLDER |
||
| 88 | ]; |
||
| 89 | |||
| 90 | if (isset($this->id) and (in_array($style, $staticStyles) or array_key_exists($style, $this->imageStyles) or array_key_exists($style, $this->videoStyles))) { |
||
| 91 | $name = $style == Larupload::COVER_FOLDER |
||
| 92 | ? $this->output['cover'] |
||
| 93 | : $this->output['name']; |
||
| 94 | |||
| 95 | $type = $this->output['type'] |
||
| 96 | ? LaruploadFileType::from($this->output['type']) |
||
| 97 | : null; |
||
| 98 | |||
| 99 | if ($name and $style == Larupload::STREAM_FOLDER) { |
||
| 100 | if ($type === LaruploadFileType::VIDEO) { |
||
| 101 | $name = pathinfo($name, PATHINFO_FILENAME) . '.m3u8'; |
||
| 102 | $path = $this->getBasePath($this->id, $style); |
||
| 103 | |||
| 104 | return "$path/$name"; |
||
| 105 | } |
||
| 106 | |||
| 107 | return null; |
||
| 108 | } |
||
| 109 | else if ($name and $this->styleHasFile($style)) { |
||
| 110 | $name = FixExceptionNamesAction::make($name, $style)->run(); |
||
| 111 | $path = $this->getBasePath($this->id, $style); |
||
| 112 | |||
| 113 | return "$path/$name"; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | return null; |
||
| 118 | } |
||
| 120 |