| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 6 | public static function groupSegmentsByMessage(SegmentInterface...$segments): array |
|
| 24 | { |
||
| 25 | 6 | $messages = []; |
|
| 26 | 6 | $groupedSegments = []; |
|
| 27 | |||
| 28 | 6 | foreach ($segments as $segment) { |
|
| 29 | 6 | if ($segment instanceof UNHMessageHeader && $groupedSegments) { |
|
|
|
|||
| 30 | 2 | $messages[] = self::groupSegmentsByName(...$groupedSegments); |
|
| 31 | 2 | $groupedSegments = []; |
|
| 32 | } |
||
| 33 | 6 | $groupedSegments[] = $segment; |
|
| 34 | } |
||
| 35 | |||
| 36 | 6 | $messages[] = self::groupSegmentsByName(...$groupedSegments); |
|
| 37 | |||
| 38 | 6 | return $messages; |
|
| 39 | } |
||
| 65 |
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.