| Total Complexity | 5 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait BuildsGroupLimitQueries |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * The maximum number of records to return per group. |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | public $groupLimit; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Add a "group limit" clause to the query. |
||
| 16 | * |
||
| 17 | * @param int $value |
||
| 18 | * @param string $column |
||
| 19 | * @return $this |
||
| 20 | */ |
||
| 21 | 116 | public function groupLimit($value, $column) |
|
| 22 | { |
||
| 23 | 116 | if ($value >= 0) { |
|
| 24 | 116 | $this->groupLimit = compact('value', 'column'); |
|
| 25 | } |
||
| 26 | |||
| 27 | 116 | return $this; |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Execute the query as a "select" statement. |
||
| 32 | * |
||
| 33 | * @param array $columns |
||
| 34 | * @return \Illuminate\Support\Collection |
||
| 35 | */ |
||
| 36 | 128 | public function get($columns = ['*']) |
|
| 57 | } |
||
| 58 | } |
||
| 59 |
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.