| Conditions | 6 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 43 | 84 | public function get($columns = ['*']) |
|
| 44 | { |
||
| 45 | 84 | $items = parent::get($columns); |
|
| 46 | |||
| 47 | 84 | if (!$this->groupLimit) { |
|
|
|
|||
| 48 | 84 | return $items; |
|
| 49 | } |
||
| 50 | |||
| 51 | 32 | $keys = ['laravel_row']; |
|
| 52 | |||
| 53 | 32 | if (is_array($this->groupLimit['column'])) { |
|
| 54 | 20 | foreach ($this->groupLimit['column'] as $i => $column) { |
|
| 55 | 20 | $keys[] = "@laravel_partition_$i := " . $this->grammar->wrap(last(explode('.', $column))); |
|
| 56 | 20 | $keys[] = "@laravel_partition_$i := " . $this->grammar->wrap('pivot_' . last(explode('.', $column))); |
|
| 57 | } |
||
| 58 | } else { |
||
| 59 | 32 | $keys[] = '@laravel_partition := ' . $this->grammar->wrap(last(explode('.', $this->groupLimit['column']))); |
|
| 60 | 32 | $keys[] = '@laravel_partition := ' . $this->grammar->wrap('pivot_' . last(explode('.', $this->groupLimit['column']))); |
|
| 61 | } |
||
| 62 | |||
| 63 | 32 | foreach ($items as $item) { |
|
| 64 | 28 | foreach ($keys as $key) { |
|
| 65 | 28 | unset($item->$key); |
|
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | 32 | return $items; |
|
| 70 | } |
||
| 72 |
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.