PMGI   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 36
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getFreeSpace() 0 4 1
1
<?php
2
3
namespace CHMLib\Header;
4
5
use Exception;
6
use CHMLib\Reader\Reader;
7
use CHMLib\Exception\UnexpectedHeaderException;
8
9
/**
10
 * A PMGI (directory listing) header of a CHM file.
11
 */
12
class PMGI extends Header
13
{
14
    /**
15
     * The length of the free space and/or the QuickRef area at the end of the directory chunk.
16
     *
17
     * @var int
18
     */
19
    protected $freeSpace;
20
21
    /**
22
     * Initializes the instance.
23
     *
24
     * @param Reader $reader The reader that provides the data.
25
     *
26
     * @throws \CHMLib\Exception\UnexpectedHeaderException Throws an UnexpectedHeaderException if the header signature is not valid.
27
     * @throws \Exception Throws an Exception in case of errors.
28
     */
29
    public function __construct(Reader $reader)
30
    {
31
        parent::__construct($reader);
32
        if ($this->headerSignature !== 'PMGI') {
33
            throw UnexpectedHeaderException::create('PMGI', $this->headerSignature);
34
        }
35
        $this->freeSpace = $reader->readUInt32();
36
    }
37
38
    /**
39
     * Get the length of the free space and/or the QuickRef area at the end of the directory chunk.
40
     *
41
     * @return int
42
     */
43
    public function getFreeSpace()
44
    {
45
        return $this->freeSpace;
46
    }
47
}
48