| Conditions | 10 | 
| Paths | 11 | 
| Total Lines | 47 | 
| Code Lines | 25 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 42 | protected function addValueByColName(&$cols, &$row, $colName, $value)  | 
            ||
| 43 |     { | 
            ||
| 44 | if(is_object($value))  | 
            ||
| 45 |         { | 
            ||
| 46 | switch($colName)  | 
            ||
| 47 |             { | 
            ||
| 48 | case '_id':  | 
            ||
| 49 |                     if(isset($value->{'$id'})) | 
            ||
| 50 |                     { | 
            ||
| 51 |                         $this->addValueByColName($cols, $row, $colName, $value->{'$id'}); | 
            ||
| 52 | break;  | 
            ||
| 53 | }  | 
            ||
| 54 | default:  | 
            ||
| 55 | $props = get_object_vars($value);  | 
            ||
| 56 | foreach($props as $key=>$newValue)  | 
            ||
| 57 |                     { | 
            ||
| 58 | $this->addValueByColName($cols, $row, $colName.'.'.$key, $newValue);  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | return;  | 
            ||
| 62 | }  | 
            ||
| 63 | $index = array_search($colName, $cols);  | 
            ||
| 64 | if($index === false)  | 
            ||
| 65 |         { | 
            ||
| 66 | $index = count($cols);  | 
            ||
| 67 | $cols[$index] = $colName;  | 
            ||
| 68 | }  | 
            ||
| 69 | if(is_array($value))  | 
            ||
| 70 |         { | 
            ||
| 71 | if(isset($value[0]) && is_object($value[0]))  | 
            ||
| 72 |             { | 
            ||
| 73 | $count = count($value);  | 
            ||
| 74 | for($i = 0; $i < $count; $i++)  | 
            ||
| 75 |                 { | 
            ||
| 76 | $this->addValueByColName($cols, $row, $colName.'['.$i.']', $value[$i]);  | 
            ||
| 77 | }  | 
            ||
| 78 | }  | 
            ||
| 79 | else  | 
            ||
| 80 |             { | 
            ||
| 81 |                 $row[$index] = implode(',', $value); | 
            ||
| 82 | }  | 
            ||
| 83 | }  | 
            ||
| 84 | else  | 
            ||
| 85 |         { | 
            ||
| 86 | $row[$index] = $value;  | 
            ||
| 87 | }  | 
            ||
| 88 | }  | 
            ||
| 89 | |||
| 113 |