1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhpIso\Descriptor; |
6
|
|
|
|
7
|
|
|
use PhpIso\Descriptor; |
8
|
|
|
|
9
|
|
|
class Factory |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @param array<int, int> $bytes |
13
|
|
|
*/ |
14
|
19 |
|
public static function create(int $type, string $stdId = '', int $version = 0, ?array $bytes = null): Descriptor |
15
|
|
|
{ |
16
|
19 |
|
return match ($type) { |
17
|
2 |
|
Type::BOOT_RECORD_DESC => new Boot($stdId, $version, $bytes), |
18
|
17 |
|
Type::PRIMARY_VOLUME_DESC => new PrimaryVolume($stdId, $version, $bytes), |
19
|
10 |
|
Type::SUPPLEMENTARY_VOLUME_DESC => new SupplementaryVolume($stdId, $version, $bytes), |
20
|
|
|
Type::PARTITION_VOLUME_DESC => new Partition($stdId, $version, $bytes), |
21
|
17 |
|
Type::TERMINATOR_DESC => new Terminator($stdId, $version, $bytes), |
22
|
10 |
|
Type::UDF_BEA_VOLUME_DESC => new UdfBeaDescriptor($stdId, $version, $bytes), |
23
|
8 |
|
Type::UDF_NSR2_VOLUME_DESC => new UdfNsr2Descriptor($stdId, $version, $bytes), |
24
|
2 |
|
Type::UDF_NSR3_VOLUME_DESC => new UdfNsr3Descriptor($stdId, $version, $bytes), |
25
|
10 |
|
Type::UDF_TEA_VOLUME_DESC => new UdfTeaDescriptor($stdId, $version, $bytes), |
26
|
19 |
|
default => throw new Exception('Invalid descriptor type received: ' . $type), |
27
|
19 |
|
}; |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|