Conditions | 5 |
Paths | 11 |
Total Lines | 19 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5.246 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 6 | public function query($query) |
|
22 | { |
||
23 | try { |
||
24 | 6 | $stmt = $this->resource->query($query, \PDO::FETCH_ASSOC); |
|
25 | 6 | if ($stmt === false) { |
|
26 | 3 | throw new Exception\InvalidArgumentException("Query cannot be executed [$query]."); |
|
27 | } |
||
28 | 6 | $results = new Resultset(); |
|
29 | 6 | foreach ($stmt as $row) { |
|
30 | 3 | $results->append($row); |
|
31 | 6 | } |
|
32 | 6 | } catch (Exception\InvalidArgumentException $e) { |
|
33 | 3 | throw $e; |
|
34 | } catch (\Exception $e) { |
||
35 | $msg = "PDOException : {$e->getMessage()} [$query]"; |
||
36 | throw new Exception\InvalidArgumentException($msg); |
||
37 | } |
||
38 | 6 | return $results; |
|
39 | } |
||
40 | |||
64 |