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