| Conditions | 4 | 
| Paths | 5 | 
| Total Lines | 53 | 
| Code Lines | 44 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 2 | 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 | ||
| 33 | private $base_url; | ||
| 34 | |||
| 35 | /** @var string */ | ||
| 36 | private $seg_filename; | ||
| 37 | |||
| 38 | /** | ||
| 39 | * @param | ||
| 40 | * @return array | ||
| 41 | */ | ||
|  | |||
| 42 | private function getFormats(): array | ||
| 43 |     { | ||
| 44 | $format = ['-c:v', $this->hls->getFormat()->getVideoCodec()]; | ||
| 45 | $audio_format = $this->hls->getFormat()->getAudioCodec(); | ||
| 46 | |||
| 47 | return $audio_format ? array_merge($format, ['-c:a', $audio_format]) : $format; | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * @param Representation $rep | ||
| 52 | * @param bool $not_last | ||
| 53 | * @return array | ||
| 54 | */ | ||
| 55 | private function playlistPath(Representation $rep, bool $not_last): array | ||
| 56 |     { | ||
| 57 | return $not_last ? [$this->dirname . "/" . $this->filename . "_" . $rep->getHeight() . "p.m3u8"] : []; | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 61 | * @param Representation $rep | ||
| 62 | * @return array | ||
| 63 | */ | ||
| 64 | private function getAudioBitrate(Representation $rep): array | ||
| 65 |     { | ||
| 66 | return $rep->getAudioKiloBitrate() ? ["-b:a", $rep->getAudioKiloBitrate() . "k"] : []; | ||
| 67 | } | ||
| 68 | |||
| 69 | /** | ||
| 70 | * @return array | ||
| 71 | */ | ||
| 72 | private function getBaseURL(): array | ||
| 73 |     { | ||
| 74 | return $this->base_url ? ["-hls_base_url", $this->base_url] : []; | ||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * @param | ||
| 79 | * @return array | ||
| 80 | */ | ||
| 81 | private function getKeyInfo(): array | ||
| 82 |     { | ||
| 83 | return $this->hls->getHlsKeyInfoFile() ? ["-hls_key_info_file", $this->hls->getHlsKeyInfoFile()] : []; | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 190 | } |