| Conditions | 8 |
| Paths | 17 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 8.7021 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 50 | 4 | public function query($query) |
|
| 51 | { |
||
| 52 | try { |
||
| 53 | 4 | $r = $this->resource->query($query); |
|
| 54 | |||
| 55 | 4 | $results = new Resultset(); |
|
| 56 | |||
| 57 | 4 | if ($r === false) { |
|
| 58 | 2 | throw new Exception\InvalidArgumentException("Query cannot be executed [$query]."); |
|
| 59 | 4 | } elseif ($r !== true && !$r instanceof \mysqli_result) { |
|
| 60 | throw new Exception\InvalidArgumentException("Query didn't return any result [$query]."); |
||
| 61 | 4 | } elseif ($r instanceof \mysqli_result) { |
|
| 62 | 3 | while ($row = $r->fetch_assoc()) { |
|
| 63 | 3 | $results->append($row); |
|
| 64 | 3 | } |
|
| 65 | 3 | } |
|
| 66 | 4 | } catch (Exception\InvalidArgumentException $e) { |
|
| 67 | 2 | throw $e; |
|
| 68 | } catch (\Exception $e) { |
||
| 69 | $msg = "MysqliException: {$e->getMessage()} [$query]"; |
||
| 70 | throw new Exception\InvalidArgumentException($msg); |
||
| 71 | } |
||
| 72 | 4 | return $results; |
|
| 73 | } |
||
| 74 | |||
| 84 |