| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 3 |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 24 | 3 | public function getItems($column = null) |
|
| 25 | { |
||
| 26 | 3 | $db = $this->getDb(); |
|
| 27 | |||
| 28 | // Validate the requested column is actually in the table |
||
| 29 | 3 | if ($column !== null) |
|
| 30 | 3 | { |
|
| 31 | 2 | $columnList = $db->getTableColumns('#__jstats'); |
|
| 32 | |||
| 33 | 2 | if (!in_array($column, array_keys($columnList))) |
|
| 34 | 2 | { |
|
| 35 | 1 | throw new \InvalidArgumentException('An invalid data source was requested.', 404); |
|
| 36 | } |
||
| 37 | 1 | } |
|
| 38 | else |
||
| 39 | { |
||
| 40 | 1 | $column = '*'; |
|
| 41 | } |
||
| 42 | |||
| 43 | 2 | return $db->setQuery( |
|
| 44 | 2 | $db->getQuery(true) |
|
| 45 | 2 | ->select($column) |
|
| 46 | 2 | ->from('#__jstats') |
|
| 47 | 2 | ->group('unique_id') |
|
| 48 | 2 | )->loadObjectList(); |
|
| 49 | } |
||
| 50 | |||
| 85 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: