PHPReader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace HughCube\IpDb\Readers;
4
5
class PHPReader extends Reader
6
{
7
    private $data;
8
9
    /**
10
     * Reader constructor.
11
     *
12
     * @param string $data
13
     *
14
     * @throws \Exception
15
     */
16
    public function __construct($data)
17
    {
18
        $this->data = $data;
19
20
        $this->init();
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function computeFileSize()
27
    {
28
        return strlen($this->data);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function read($offset, $length)
35
    {
36
        return substr($this->data, $offset, $length);
37
    }
38
}
39