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

VideoStrategy::guessFormat()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
c 0
b 0
f 0
nc 6
nop 0
dl 0
loc 17
rs 9.2222
1
<?php
2
3
namespace Jobtech\LaravelChunky\Strategies;
4
5
use FFMpeg\Format\Video\Ogg;
6
use FFMpeg\Format\Video\WebM;
7
use FFMpeg\Format\Video\WMV;
8
use FFMpeg\Format\Video\WMV3;
9
use FFMpeg\Format\Video\X264;
10
use Illuminate\Support\Arr;
11
use Jobtech\LaravelChunky\Strategies\Concerns\ChecksIntegrity;
12
use Jobtech\LaravelChunky\Strategies\Concerns\HandlesFFMpeg;
13
use ProtoneMedia\LaravelFFMpeg\FFMpeg\CopyFormat;
14
15
class VideoStrategy extends MergeStrategy
16
{
17
    use ChecksIntegrity,
18
        HandlesFFMpeg;
19
20
    public function merge()
21
    {
22
        $this->mergeWithFFMpeg();
23
24
        $this->deleteChunks($this->folder);
0 ignored issues
show
Bug introduced by
The method deleteChunks() does not exist on Jobtech\LaravelChunky\Strategies\VideoStrategy. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

24
        $this->/** @scrutinizer ignore-call */ 
25
               deleteChunks($this->folder);
Loading history...
25
26
        return $this->mergeContents();
27
    }
28
29
    public function guessFormat()
30
    {
31
        $extension = strtolower(Arr::last(explode('.', $this->destination())));
32
33
        switch ($extension) {
34
            case 'oog':
35
                return new Ogg;
36
            case 'webm':
37
                return new WebM;
38
            case 'wmv':
39
                return new WMV;
40
            case 'wmv3':
41
                return new WMV3;
42
            case 'mp4':
43
                return new X264;
44
            default:
45
                return new CopyFormat;
46
        }
47
    }
48
}
49