Factory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 12
c 1
b 0
f 0
dl 0
loc 18
ccs 11
cts 12
cp 0.9167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 1
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