Partition::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 11
cp 0
rs 9.9332
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpIso\Descriptor;
6
7
use PhpIso\Descriptor;
8
use PhpIso\IsoFile;
9
use PhpIso\Util\Buffer;
10
11
class Partition extends Descriptor
12
{
13
    /**
14
     * The "Partition Volume Descriptors"'s System Identifier
15
     */
16
    public string $systemID;
17
18
    /**
19
     * The "Partition Volume Descriptors"'s Partition Identifier
20
     */
21
    public string $volPartitionID;
22
23
    /**
24
     * The "Partition Volume Descriptors"'s Partition location
25
     */
26
    public int $volPartitionLocation;
27
28
    /**
29
     * The "Partition Volume Descriptors"'s Partition size
30
     */
31
    public int $volPartitionSize;
32
33
    public string $name = 'Partition volume descriptor';
34
35
    protected int $type = Type::PARTITION_VOLUME_DESC;
36
37
    public function init(IsoFile $isoFile, int &$offset): void
38
    {
39
        if ($this->bytes === null) {
40
            return;
41
        }
42
43
        $unused = $this->bytes[$offset];
44
        $offset++;
45
46
        $this->systemID = Buffer::readAString($this->bytes, 32, $offset);
47
        $this->volPartitionID = Buffer::readDString($this->bytes, 32, $offset);
48
49
        $this->volPartitionLocation = Buffer::readMSB($this->bytes, 8, $offset);
50
        $this->volPartitionSize = Buffer::readMSB($this->bytes, 8, $offset);
51
52
        // free some space...
53
        $this->bytes = null;
54
        unset($unused);
55
    }
56
}
57