| Conditions | 4 |
| Paths | 8 |
| Total Lines | 27 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | 2 | public function getHandle(): mixed |
|
| 33 | { |
||
| 34 | 2 | $transcodingConfig = $this->configProvider->getTranscodingConfig(); |
|
| 35 | |||
| 36 | 2 | if (!in_array($this->bitrate, $transcodingConfig['allowed_bitrates'], true)) { |
|
| 37 | 1 | $this->bitrate = $transcodingConfig['bitrate']; |
|
| 38 | } |
||
| 39 | |||
| 40 | 2 | if (!in_array($this->codec, $transcodingConfig['allowed_codecs'], true)) { |
|
| 41 | 1 | $this->codec = $transcodingConfig['codec']; |
|
| 42 | } |
||
| 43 | |||
| 44 | 2 | $command = sprintf( |
|
| 45 | 2 | 'ffmpeg -i %s -vn -nostats -ar 44100 -ac 2 -b:a %dk -f %s pipe:1 2>/dev/null', |
|
| 46 | 2 | escapeshellarg((string)$this->file_path), |
|
| 47 | 2 | $this->bitrate, |
|
| 48 | 2 | escapeshellarg($this->codec), |
|
| 49 | 2 | ); |
|
| 50 | |||
| 51 | 2 | $handle = $this->popenWrapper->run($command); |
|
| 52 | |||
| 53 | 2 | if ($handle === null) { |
|
| 54 | // throw dedicated exception |
||
| 55 | 1 | throw new RuntimeException(); |
|
| 56 | } |
||
| 57 | |||
| 58 | 1 | return $handle; |
|
| 59 | } |
||
| 61 |