| Conditions | 5 |
| Paths | 11 |
| Total Lines | 19 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5.246 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 2 | public function query($query) |
|
| 35 | { |
||
| 36 | try { |
||
| 37 | 2 | $stmt = $this->resource->query($query, \PDO::FETCH_ASSOC); |
|
| 38 | 2 | if ($stmt === false) { |
|
| 39 | 1 | throw new Exception\InvalidArgumentException("Query cannot be executed [$query]."); |
|
| 40 | } |
||
| 41 | 2 | $results = new Resultset(); |
|
| 42 | 2 | foreach ($stmt as $row) { |
|
| 43 | 2 | $results->append($row); |
|
| 44 | 2 | } |
|
| 45 | 2 | } catch (Exception\InvalidArgumentException $e) { |
|
| 46 | 1 | throw $e; |
|
| 47 | } catch (\Exception $e) { |
||
| 48 | $msg = "PDOException : {$e->getMessage()} [$query]"; |
||
| 49 | throw new Exception\InvalidArgumentException($msg); |
||
| 50 | } |
||
| 51 | 2 | return $results; |
|
| 52 | } |
||
| 53 | |||
| 76 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: