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
![]() |
|||
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 |