MachineFloatingPoint::write()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 10
c 2
b 0
f 0
nc 8
nop 1
dl 0
loc 18
ccs 11
cts 11
cp 1
crap 4
rs 9.9332
1
<?php
2
3
namespace SPSS\Sav\Record\Info;
4
5
use SPSS\Buffer;
6
use SPSS\Sav\Record\Info;
7
8
class MachineFloatingPoint extends Info
9
{
10
    const SUBTYPE = 4;
11
12
    /**
13
     * @var double
14
     */
15
    public $sysmis;
16
17
    /**
18
     * @var double
19
     */
20
    public $highest;
21
22
    /**
23
     * @var double
24
     */
25
    public $lowest;
26
27
    /**
28
     * @var int Always set to 8.
29
     */
30
    protected $dataSize = 8;
31
32
    /**
33
     * @var int Always set to 3.
34
     */
35
    protected $dataCount = 3;
36
37
    /**
38
     * @param Buffer $buffer
39
     */
40 2
    public function read(Buffer $buffer)
41
    {
42 2
        parent::read($buffer);
43 2
        $this->sysmis = $buffer->readDouble();
44 2
        $this->highest = $buffer->readDouble();
45 2
        $this->lowest = $buffer->readDouble();
46 2
    }
47
48
    /**
49
     * @param Buffer $buffer
50
     */
51 2
    public function write(Buffer $buffer)
52
    {
53 2
        if (! $this->sysmis) {
54 1
            $this->sysmis = -PHP_FLOAT_MAX;
55
        }
56
57 2
        if (! $this->highest) {
58 1
            $this->highest = PHP_FLOAT_MAX;
59
        }
60
61 2
        if (! $this->lowest) {
62 1
            $this->lowest = -PHP_FLOAT_MAX;
63
        }
64
65 2
        parent::write($buffer);
66 2
        $buffer->writeDouble($this->sysmis);
67 2
        $buffer->writeDouble($this->highest);
68 2
        $buffer->writeDouble($this->lowest);
69 2
    }
70
}
71