Test Failed
Push — master ( ba03f2...dee2b3 )
by Mostafa
58s queued 15s
created

AudioStyle   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A make() 0 3 1
A extension() 0 13 4
1
<?php
2
3
namespace Mostafaznv\Larupload\DTOs\Style;
4
5
use FFMpeg\Format\Audio\Aac;
6
use FFMpeg\Format\Audio\Flac;
7
use FFMpeg\Format\Audio\Mp3;
8
use FFMpeg\Format\Audio\Wav;
9
10
11
class AudioStyle extends Style
12
{
13
    public readonly Mp3|Aac|Wav|Flac $format;
14
15
16
    public function __construct(string $name, Mp3|Aac|Wav|Flac $format = new Mp3)
17
    {
18
        parent::__construct($name);
19
20
        $this->format = $format;
0 ignored issues
show
Bug introduced by
The property format is declared read-only in Mostafaznv\Larupload\DTOs\Style\AudioStyle.
Loading history...
21
22
    }
23
24
    public static function make(string $name, Mp3|Aac|Wav|Flac $format = new Mp3): self
25
    {
26
        return new self($name, $format);
27
    }
28
29
    public function extension(): ?string
30
    {
31
        if ($this->format instanceof Aac) {
32
            return 'aac';
33
        }
34
        else if ($this->format instanceof Wav) {
35
            return 'wav';
36
        }
37
        else if ($this->format instanceof Flac) {
38
            return 'flac';
39
        }
40
41
        return 'mp3';
42
    }
43
}
44