| Conditions | 11 |
| Paths | 116 |
| Total Lines | 44 |
| Code Lines | 25 |
| 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 |
||
| 77 | public function save(string $path = null) |
||
| 78 | { |
||
| 79 | $outputMedia = $path ? $this->getDisk()->makeMedia($path) : null; |
||
| 80 | |||
| 81 | if ($this->concatWithTranscoding) { |
||
| 82 | $this->addConcatFilterAndMapping($outputMedia); |
||
| 83 | } |
||
| 84 | |||
| 85 | if ($this->maps->isNotEmpty()) { |
||
| 86 | return $this->saveWithMappings(); |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($this->format && $this->onProgressCallback) { |
||
| 90 | $this->applyProgressListenerToFormat($this->format); |
||
| 91 | } |
||
| 92 | |||
| 93 | if ($this->timelapseFramerate > 0) { |
||
| 94 | $this->addTimelapseParametersToFormat(); |
||
| 95 | } |
||
| 96 | |||
| 97 | if ($this->driver->isConcat()) { |
||
| 98 | $this->driver->saveFromSameCodecs($outputMedia->getLocalPath()); |
||
| 99 | } elseif ($this->driver->isFrame()) { |
||
| 100 | $data = $this->driver->save( |
||
| 101 | optional($outputMedia)->getLocalPath(), |
||
| 102 | $this->getAccuracy(), |
||
| 103 | $this->returnFrameContents |
||
| 104 | ); |
||
| 105 | |||
| 106 | if ($this->returnFrameContents) { |
||
| 107 | return $data; |
||
| 108 | } |
||
| 109 | } else { |
||
| 110 | $this->driver->save($this->format, $outputMedia->getLocalPath()); |
||
| 111 | } |
||
| 112 | |||
| 113 | $outputMedia->copyAllFromTemporaryDirectory($this->visibility); |
||
| 114 | $outputMedia->setVisibility($this->visibility); |
||
| 115 | |||
| 116 | if ($this->onProgressCallback) { |
||
| 117 | call_user_func($this->onProgressCallback, 100); |
||
| 118 | } |
||
| 119 | |||
| 120 | return $this->getMediaOpener(); |
||
| 121 | } |
||
| 164 |