Completed
Push — master ( 1d7ad2...efdc9e )
by Michele
05:30
created

PMGL   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 0
cbo 3
dl 0
loc 73
ccs 10
cts 15
cp 0.6667
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getFreeSpace() 0 4 1
A getPreviousChunk() 0 4 1
A getNextChunk() 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 PMGL (directory listing) header of a CHM file.
11
 */
12
class PMGL 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
     * The chunk number of the previous listing chunk when reading directory in sequence (-1 if this is the first listing chunk).
23
     *
24
     * @var int
25
     */
26
    protected $previousChunk;
27
28
    /**
29
     * The chunk number of the next listing chunk when reading directory in sequence (-1 if this is the last listing chunk).
30
     *
31
     * @var int
32
     */
33
    protected $nextChunk;
34
35
    /**
36
     * Initializes the instance.
37
     *
38
     * @param Reader $reader The reader that provides the data.
39
     *
40
     * @throws UnexpectedHeaderException Throws an UnexpectedHeaderException if the header signature is not valid.
41
     * @throws Exception Throws an Exception in case of errors.
42
     */
43 1
    public function __construct(Reader $reader)
44
    {
45 1
        parent::__construct($reader);
46 1
        if ($this->headerSignature !== 'PMGL') {
47
            throw UnexpectedHeaderException::create('PMGL', $this->headerSignature);
48
        }
49 1
        $this->freeSpace = $reader->readUInt32();
50 1
        /* Unknown (0) */ $reader->readUInt32();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51 1
        $this->previousChunk = $reader->readInt32();
52 1
        $this->nextChunk = $reader->readInt32();
53 1
    }
54
55
    /**
56
     * Get the length of the free space and/or the QuickRef area at the end of the directory chunk.
57
     *
58
     * @return int
59
     */
60 1
    public function getFreeSpace()
61
    {
62 1
        return $this->freeSpace;
63
    }
64
65
    /**
66
     * Get the chunk number of the previous listing chunk when reading directory in sequence (-1 if this is the first listing chunk).
67
     *
68
     * @return int
69
     */
70
    public function getPreviousChunk()
71
    {
72
        return $this->previousChunk;
73
    }
74
75
    /**
76
     * Get the chunk number of the next listing chunk when reading directory in sequence (-1 if this is the last listing chunk).
77
     *
78
     * @return int
79
     */
80
    public function getNextChunk()
81
    {
82
        return $this->nextChunk;
83
    }
84
}
85