Passed
Pull Request — master (#232)
by Pascal
02:29
created

AdvancedMedia::buildCommand()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 19
rs 9.9332
1
<?php
2
3
namespace ProtoneMedia\LaravelFFMpeg\FFMpeg;
4
5
use FFMpeg\Media\AdvancedMedia as MediaAdvancedMedia;
6
use Illuminate\Support\Arr;
7
8
class AdvancedMedia extends MediaAdvancedMedia
9
{
10
    use InteractsWithHttpHeaders;
11
12
    public static function make(MediaAdvancedMedia $media)
13
    {
14
        return new static($media->getInputs(), $media->getFFMpegDriver(), FFProbe::make($media->getFFProbe()));
15
    }
16
17
    /**
18
     * @return array
19
     */
20
    protected function buildCommand()
21
    {
22
        $command = parent::buildCommand();
23
24
        $inputKey = array_search(Arr::first($this->getInputs()), $command) - 1;
25
26
        foreach ($this->getInputs() as $key => $path) {
27
            $headers = $this->headers[$key];
28
29
            if (empty($headers)) {
30
                $inputKey += 2;
31
                continue;
32
            }
33
34
            $command = static::mergeBeforeKey($command, $inputKey, static::compileHeaders($headers));
35
            $inputKey += 4;
36
        }
37
38
        return $command;
39
    }
40
}
41