| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 2 |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 60 | 2 | public function save($data) |
|
| 61 | { |
||
| 62 | 2 | $db = $this->getDb(); |
|
| 63 | |||
| 64 | // Set the modified date of the record |
||
| 65 | 2 | $data->modified = (new \DateTime('now', new \DateTimeZone('UTC')))->format($db->getDateFormat()); |
|
| 66 | |||
| 67 | // Check if a row exists for this unique ID and update the existing record if so |
||
| 68 | 2 | $recordExists = $db->setQuery( |
|
| 69 | 2 | $db->getQuery(true) |
|
| 70 | 2 | ->select('unique_id') |
|
| 71 | 2 | ->from('#__jstats') |
|
| 72 | 2 | ->where('unique_id = ' . $db->quote($data->unique_id)) |
|
| 73 | 2 | )->loadResult(); |
|
| 74 | |||
| 75 | if ($recordExists) |
||
| 76 | 2 | { |
|
| 77 | 1 | $db->updateObject('#__jstats', $data, ['unique_id']); |
|
| 78 | 1 | } |
|
| 79 | else |
||
| 80 | { |
||
| 81 | 1 | $db->insertObject('#__jstats', $data, ['unique_id']); |
|
|
|
|||
| 82 | } |
||
| 83 | 2 | } |
|
| 84 | } |
||
| 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: