| Conditions | 10 |
| Paths | 10 |
| Total Lines | 25 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 32 | protected function ffmpeg(UploadedFile $file = null, AudioStyle|VideoStyle|null $style = null): FFMpeg |
||
| 33 | { |
||
| 34 | $force = false; |
||
| 35 | |||
| 36 | if ($style and isset($this->ffmpeg)) { |
||
| 37 | $media = $this->ffmpeg->getMedia(); |
||
| 38 | |||
| 39 | // @codeCoverageIgnoreStart |
||
| 40 | // it's an unlikely scenario, however, we must consider it |
||
| 41 | if ($style instanceof AudioStyle and $media instanceof Video) { |
||
| 42 | $force = true; |
||
| 43 | } |
||
| 44 | // @codeCoverageIgnoreEnd |
||
| 45 | |||
| 46 | if ($style instanceof VideoStyle and $media instanceof Audio) { |
||
| 47 | $force = true; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | |||
| 52 | if (!isset($this->ffmpeg) or $file or $force) { |
||
| 53 | $this->ffmpeg = new FFMpeg($this->file, $this->disk, $this->dominantColorQuality); |
||
| 54 | } |
||
| 55 | |||
| 56 | return $this->ffmpeg; |
||
| 57 | } |
||
| 59 |