| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function read(Buffer $buffer) |
||
| 28 | { |
||
| 29 | parent::read($buffer); |
||
| 30 | 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 | 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 | $itemCount = $this->dataCount / 3; |
||
| 45 | for ($i = 0; $i < $itemCount; $i++) { |
||
| 46 | $this->data[] = [ |
||
| 47 | $buffer->readInt(), // The measurement type of the variable |
||
| 48 | $buffer->readInt(), // The width of the display column for the variable in characters. |
||
| 49 | $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.