Completed
Push — master ( dd1269...21c3dd )
by Sam
02:11
created

MachineFloatingPoint::write()   A

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
// Available as of PHP 7.2.0.
9
if (! defined('PHP_FLOAT_MAX')) {
10
    define('PHP_FLOAT_MAX', 1.7976931348623e+308);
11
}
12
13
class MachineFloatingPoint extends Info
14
{
15
    const SUBTYPE = 4;
16
17
    /**
18
     * @var double
19
     */
20
    public $sysmis;
21
22
    /**
23
     * @var double
24
     */
25
    public $highest;
26
27
    /**
28
     * @var double
29
     */
30
    public $lowest;
31
32
    /**
33
     * @var int Always set to 8.
34
     */
35
    protected $dataSize = 8;
36
37
    /**
38
     * @var int Always set to 3.
39
     */
40
    protected $dataCount = 3;
41
42
    /**
43
     * @param Buffer $buffer
44
     */
45 7
    public function read(Buffer $buffer)
46
    {
47 7
        parent::read($buffer);
48 7
        $this->sysmis = $buffer->readDouble();
49 7
        $this->highest = $buffer->readDouble();
50 7
        $this->lowest = $buffer->readDouble();
51 7
    }
52
53
    /**
54
     * @param Buffer $buffer
55
     */
56 7
    public function write(Buffer $buffer)
57
    {
58 7
        if (! $this->sysmis) {
59 6
            $this->sysmis = -PHP_FLOAT_MAX;
60
        }
61
62 7
        if (! $this->highest) {
63 6
            $this->highest = PHP_FLOAT_MAX;
64
        }
65
66 7
        if (! $this->lowest) {
67 6
            $this->lowest = -PHP_FLOAT_MAX;
68
        }
69
70 7
        parent::write($buffer);
71 7
        $buffer->writeDouble($this->sysmis);
72 7
        $buffer->writeDouble($this->highest);
73 7
        $buffer->writeDouble($this->lowest);
74 7
    }
75
}
76