Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.8437 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 5 | public function read(Buffer $buffer) |
|
28 | { |
||
29 | 5 | parent::read($buffer); |
|
30 | 5 | if ($this->dataSize != 4) { |
|
31 | throw new Exception( |
||
32 | sprintf('Error reading record type 7 subtype 11: bad data element length [%s]. Expecting 4.', |
||
33 | $this->dataSize |
||
34 | ) |
||
35 | ); |
||
36 | } |
||
37 | 5 | if (($this->dataCount % 3) != 0) { |
|
38 | throw new Exception( |
||
39 | sprintf('Error reading record type 7 subtype 11: number of data elements [%s] is not a multiple of 3.', |
||
40 | $this->dataCount |
||
41 | ) |
||
42 | ); |
||
43 | } |
||
44 | 5 | $itemCount = $this->dataCount / 3; |
|
45 | 5 | for ($i = 0; $i < $itemCount; $i++) { |
|
46 | 5 | $this->data[] = [ |
|
47 | 5 | $buffer->readInt(), // The measurement type of the variable |
|
48 | 5 | $buffer->readInt(), // The width of the display column for the variable in characters. |
|
49 | 5 | $buffer->readInt(), // The alignment of the variable |
|
50 | ]; |
||
70 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.