| Conditions | 10 |
| Paths | 16 |
| Total Lines | 31 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 20 | public function execute(array $data = []) : ResultInterface |
||
| 21 | { |
||
| 22 | $data = array_values($data); |
||
| 23 | foreach ($data as $i => $v) { |
||
| 24 | switch (gettype($v)) { |
||
| 25 | case 'boolean': |
||
| 26 | case 'integer': |
||
| 27 | $data[$i] = (int) $v; |
||
| 28 | break; |
||
| 29 | case 'array': |
||
| 30 | $data[$i] = implode(',', $v); |
||
| 31 | break; |
||
| 32 | case 'object': |
||
| 33 | $data[$i] = serialize($data[$i]); |
||
| 34 | break; |
||
| 35 | case 'resource': |
||
| 36 | if (is_resource($v) && get_resource_type($v) === 'stream') { |
||
| 37 | $data[$i] = stream_get_contents($data[$i]); |
||
| 38 | } else { |
||
| 39 | $data[$i] = serialize($data[$i]); |
||
| 40 | } |
||
| 41 | break; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | array_unshift($data, $this->statement); |
||
| 45 | $temp = call_user_func_array("\ibase_execute", $data); |
||
| 46 | if (!$temp) { |
||
| 47 | throw new DBException('Could not execute query : '.\ibase_errmsg()); |
||
| 48 | } |
||
| 49 | return new Result($temp, $data, $this->driver); |
||
| 50 | } |
||
| 51 | } |