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

AudioStyle::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 10
c 1
b 0
f 1
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