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

AdvancedMedia   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 3 1
A buildCommand() 0 19 3
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