Passed
Pull Request — master (#9)
by Filippo
10:22
created

HandlesFFMpeg   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 14
c 1
b 1
f 1
dl 0
loc 38
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A visibility() 0 5 1
A mergeWithFFMpeg() 0 15 2
1
<?php
2
3
namespace Jobtech\LaravelChunky\Strategies\Concerns;
4
5
use Illuminate\Support\Arr;
6
use ProtoneMedia\LaravelFFMpeg\Support\FFMpeg;
7
8
trait HandlesFFMpeg
9
{
10
    public function mergeWithFFMpeg(): void
11
    {
12
        $exporter = FFMpeg::fromDisk($this->manager->chunksFilesystem())
13
            ->open($this->mapChunksToArray())
0 ignored issues
show
Bug introduced by
It seems like mapChunksToArray() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
            ->open($this->/** @scrutinizer ignore-call */ mapChunksToArray())
Loading history...
14
            ->export()
15
            ->inFormat($this->guessFormat())
16
            ->concatWithoutTranscoding();
17
18
        if (! empty($visibility = $this->visibility())) {
19
            $exporter->withVisibility($visibility);
20
        }
21
22
        $exporter->toDisk(
23
            $this->manager->getMergeDisk()
24
        )->save($this->destination);
25
    }
26
27
    /**
28
     * Retrieve visibility option.
29
     *
30
     * @return string|null
31
     */
32
    public function visibility(): ?string
33
    {
34
        return Arr::get(
35
            $this->manager->getMergeOptions(),
36
            'visibility'
37
        );
38
    }
39
40
    /**
41
     * Guess format from destination file extension.
42
     *
43
     * @return mixed
44
     */
45
    abstract public function guessFormat();
46
}
47