Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | public static function getByUsername($username, PdoDatabase $database) |
||
13 | { |
||
14 | $statement = $database->prepare(<<<SQL |
||
15 | SELECT * |
||
16 | FROM antispoofcache |
||
17 | WHERE username = :id AND timestamp > date_sub(now(), interval 3 hour) |
||
18 | LIMIT 1 |
||
19 | SQL |
||
20 | ); |
||
21 | $statement->bindValue(":id", $username); |
||
22 | |||
23 | $statement->execute(); |
||
24 | |||
25 | $resultObject = $statement->fetchObject(get_called_class()); |
||
26 | |||
27 | if ($resultObject != false) { |
||
28 | $resultObject->isNew = false; |
||
29 | $resultObject->setDatabase($database); |
||
30 | } |
||
31 | |||
32 | return $resultObject; |
||
33 | } |
||
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.