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