UncompressedSection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getContents() 0 12 2
1
<?php
2
3
namespace CHMLib\Section;
4
5
use CHMLib\CHM;
6
7
/**
8
 * Represent an uncompressed section of data in a CHM file.
9
 */
10
class UncompressedSection extends Section
11
{
12
    /**
13
     * Initializes the instance.
14
     *
15
     * @param \CHMLib\CHM $chm The parent CHM file.
16
     */
17 4
    public function __construct(CHM $chm)
18
    {
19 4
        parent::__construct($chm);
20 4
        $this->sectionOffset = $chm->getITSF()->getContentOffset();
21 4
    }
22
23
    /**
24
     * {@inheritdoc}
25
     *
26
     * @see \CHMLib\Section\Section::getContents()
27
     */
28 10
    public function getContents($offset, $length)
29
    {
30 10
        if ($length === 0) {
31 3
            $result = '';
32
        } else {
33 7
            $reader = $this->chm->getReader();
34 7
            $reader->setPosition($this->sectionOffset + $offset);
35 7
            $result = $reader->readString($length);
36
        }
37
38 10
        return $result;
39
    }
40
}
41