| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 63 | public function save() |
||
| 64 | { |
||
| 65 | if ($this->isNew) { |
||
| 66 | // insert |
||
| 67 | // clear old data first |
||
| 68 | $this->dbObject->exec("delete from antispoofcache where timestamp < date_sub(now(), interval 3 hour);"); |
||
| 69 | |||
| 70 | $statement = $this->dbObject->prepare("INSERT INTO antispoofcache (username, data) VALUES (:username, :data);"); |
||
| 71 | $statement->bindValue(":username", $this->username); |
||
| 72 | $statement->bindValue(":data", $this->data); |
||
| 73 | |||
| 74 | if ($statement->execute()) { |
||
| 75 | $this->isNew = false; |
||
| 76 | $this->id = $this->dbObject->lastInsertId(); |
||
|
|
|||
| 77 | } |
||
| 78 | else { |
||
| 79 | throw new Exception($statement->errorInfo()); |
||
| 80 | } |
||
| 84 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.