Conditions | 11 |
Paths | 12 |
Total Lines | 32 |
Code Lines | 24 |
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 |
||
51 | private function getLine(\SimpleXMLElement $child): array |
||
52 | { |
||
53 | $arrayOutput = []; |
||
54 | foreach ($this->arraySettings['CustomOrder']['Lines@Read'] as $strElement => $strType) { |
||
55 | switch ($strType) { |
||
56 | case 'Item': |
||
57 | $arrayOutput['Item'] = $this->getLineItem($child->children('cac', true)->Item); |
||
58 | break; |
||
59 | case 'Multiple': |
||
60 | $intLineNo = 0; |
||
61 | foreach ($child->children('cac', true)->$strElement as $value2) { |
||
62 | $intLineNo++; |
||
63 | $intLineStr = ($intLineNo < 10 ? '0' : '') . $intLineNo; |
||
64 | $arrayOutput[$strElement][$intLineStr] = $this->getElements($value2); |
||
65 | } |
||
66 | break; |
||
67 | case 'Single': |
||
68 | if (count($child->children('cbc', true)->$strElement) !== 0) { |
||
69 | $arrayOutput[$strElement] = $child->children('cbc', true)->$strElement->__toString(); |
||
70 | } |
||
71 | if (count($child->children('cac', true)->$strElement) !== 0) { |
||
72 | $arrayOutput[$strElement] = $this->getElements($child->children('cac', true)->$strElement); |
||
73 | } |
||
74 | break; |
||
75 | case 'SingleTag': |
||
76 | if (count($child->children('cbc', true)->$strElement) !== 0) { |
||
77 | $arrayOutput[$strElement] = $this->getElementSingle($child->children('cbc', true)->$strElement); |
||
78 | } |
||
79 | break; |
||
80 | } |
||
81 | } |
||
82 | return $arrayOutput; |
||
83 | } |
||
116 |