| Conditions | 17 | 
| Paths | 50 | 
| Total Lines | 49 | 
| Code Lines | 27 | 
| 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  | 
            ||
| 36 | private function convertXmlNode($node)  | 
            ||
| 37 |     { | 
            ||
| 38 | $output = [];  | 
            ||
| 39 | |||
| 40 |         for ($i = 0, $m = $node->childNodes->length; $i < $m; $i++) { | 
            ||
| 41 | $child = $node->childNodes->item($i);  | 
            ||
| 42 | $v = $this->convertDomNode($child);  | 
            ||
| 43 | |||
| 44 |             if (isset($child->tagName)) { | 
            ||
| 45 | $t = $child->tagName;  | 
            ||
| 46 |                 if (!isset($output[$t])) { | 
            ||
| 47 | $output[$t] = array();  | 
            ||
| 48 | }  | 
            ||
| 49 | $output[$t][] = $v;  | 
            ||
| 50 |             } elseif ($v || $v === '0') { | 
            ||
| 51 | $output = (string)$v;  | 
            ||
| 52 | }  | 
            ||
| 53 | }  | 
            ||
| 54 | |||
| 55 | // Has attributes but isn't an array  | 
            ||
| 56 |         if ($node->attributes->length && !is_array($output)) { | 
            ||
| 57 | // Change output into an array.  | 
            ||
| 58 |             $output = array('@content' => $output); | 
            ||
| 59 | }  | 
            ||
| 60 | |||
| 61 |         if (is_array($output)) { | 
            ||
| 62 |             if ($node->attributes->length) { | 
            ||
| 63 | $a = array();  | 
            ||
| 64 |                 foreach ($node->attributes as $attrName => $attrNode) { | 
            ||
| 65 | $a[$attrName] = (string)$attrNode->value;  | 
            ||
| 66 | }  | 
            ||
| 67 | $output['@attributes'] = $a;  | 
            ||
| 68 | }  | 
            ||
| 69 | |||
| 70 |             foreach ($output as $t => $v) { | 
            ||
| 71 | // We are combining arrays for rdf:Bag, rdf:Alt, rdf:Seq  | 
            ||
| 72 |                 if (in_array($t, self::POSSIBLE_CONTAINERS)) { | 
            ||
| 73 |                     if (!array_key_exists(self::RDF_LI, $v[0])) { | 
            ||
| 74 | break;  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | $output = $v[0][self::RDF_LI];  | 
            ||
| 78 |                 } elseif (is_array($v) && count($v) == 1 && $t != '@attributes') { | 
            ||
| 79 | $output[$t] = $v[0];  | 
            ||
| 80 | }  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | return $output;  | 
            ||
| 85 | }  | 
            ||
| 124 | 
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.