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

AudioStrategy::guessFormat()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 6
eloc 14
c 1
b 1
f 1
nc 6
nop 0
dl 0
loc 17
rs 9.2222
1
<?php
2
3
namespace Jobtech\LaravelChunky\Strategies;
4
5
use FFMpeg\Format\Audio\Aac;
6
use FFMpeg\Format\Audio\Flac;
7
use FFMpeg\Format\Audio\Mp3;
8
use FFMpeg\Format\Audio\Vorbis;
9
use FFMpeg\Format\Audio\Wav;
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 AudioStrategy 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\AudioStrategy. 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
    /**
30
     * {@inheritdoc}
31
     */
32
    public function guessFormat()
33
    {
34
        $extension = strtolower(Arr::last(explode('.', $this->destination())));
35
36
        switch ($extension) {
37
            case 'aac':
38
                return new Aac;
39
            case 'flac':
40
                return new Flac;
41
            case 'mp3':
42
                return new Mp3;
43
            case 'oog':
44
                return new Vorbis;
45
            case 'wav':
46
                return new Wav;
47
            default:
48
                return new CopyFormat;
49
        }
50
    }
51
}
52