Conditions | 7 |
Paths | 10 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 7.3229 |
Changes | 0 |
1 | <?php |
||
44 | 3 | public function query($query, $resultsetType = Resultset::TYPE_ARRAY) |
|
45 | { |
||
46 | try { |
||
47 | 3 | $r = $this->zendAdapter->query($query)->execute(); |
|
|
|||
48 | 3 | $results = new Resultset($resultsetType); |
|
49 | 3 | if ($r instanceof \Zend\Db\ResultSet\ResultSet) { |
|
50 | foreach ($r as $row) { |
||
51 | $results->append((array) $row); |
||
52 | } |
||
53 | 3 | } elseif ($r instanceof \Zend\Db\Adapter\Driver\ResultInterface && $r->getFieldCount() > 0) { |
|
54 | 2 | foreach ($r as $row) { |
|
55 | 2 | $results->append($row); |
|
56 | 2 | } |
|
57 | 2 | } |
|
58 | 3 | } catch (\Exception $e) { |
|
59 | 2 | $msg = "ZendDb2 adapter query error: {$e->getMessage()} [$query]"; |
|
60 | 2 | throw new Exception\InvalidArgumentException($msg); |
|
61 | } |
||
62 | |||
63 | 3 | return $results; |
|
64 | } |
||
65 | |||
76 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: