| 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 |
||
| 95 | public function save(string $path = null) |
||
| 96 | { |
||
| 97 | $outputMedia = $path ? $this->getDisk()->makeMedia($path) : null; |
||
| 98 | |||
| 99 | if ($this->concatWithTranscoding) { |
||
| 100 | $this->addConcatFilterAndMapping($outputMedia); |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($this->maps->isNotEmpty()) { |
||
| 104 | return $this->saveWithMappings(); |
||
| 105 | } |
||
| 106 | |||
| 107 | if ($this->format && $this->onProgressCallback) { |
||
| 108 | $this->applyProgressListenerToFormat($this->format); |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($this->timelapseFramerate > 0) { |
||
| 112 | $this->addTimelapseParametersToFormat(); |
||
| 113 | } |
||
| 114 | |||
| 115 | if ($this->driver->isConcat()) { |
||
| 116 | $this->driver->saveFromSameCodecs($outputMedia->getLocalPath()); |
||
| 117 | } elseif ($this->driver->isFrame()) { |
||
| 118 | $data = $this->driver->save( |
||
| 119 | optional($outputMedia)->getLocalPath(), |
||
| 120 | $this->getAccuracy(), |
||
| 121 | $this->returnFrameContents |
||
| 122 | ); |
||
| 123 | |||
| 124 | if ($this->returnFrameContents) { |
||
| 125 | return $data; |
||
| 126 | } |
||
| 127 | } else { |
||
| 128 | $this->driver->save($this->format, $outputMedia->getLocalPath()); |
||
| 129 | } |
||
| 130 | |||
| 131 | $outputMedia->copyAllFromTemporaryDirectory($this->visibility); |
||
| 132 | $outputMedia->setVisibility($this->visibility); |
||
| 133 | |||
| 134 | if ($this->onProgressCallback) { |
||
| 135 | call_user_func($this->onProgressCallback, 100, 0, 0); |
||
| 136 | } |
||
| 137 | |||
| 138 | return $this->getMediaOpener(); |
||
| 139 | } |
||
| 182 |