Conditions | 19 |
Paths | 8 |
Total Lines | 65 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
86 | protected function process(&$uTarget, $uNode, $uLoadingFlags) |
||
87 | { |
||
88 | $tQueue = [ |
||
89 | [[], $uNode, $uLoadingFlags, &$uTarget, null, false] |
||
90 | ]; |
||
91 | |||
92 | do { |
||
93 | $tItem = array_pop($tQueue); |
||
94 | |||
95 | if ($tItem[4] === null) { |
||
96 | $tRef = &$tItem[3]; |
||
97 | } else { |
||
98 | $tRef = &$tItem[3][$tItem[4]]; |
||
99 | } |
||
100 | |||
101 | if (is_scalar($tItem[1]) || $tItem[1] === null) { |
||
102 | if (!isset($tRef) || ($tItem[2] & self::OVERWRITE) === self::OVERWRITE) { |
||
103 | $tRef = $tItem[1]; |
||
104 | } |
||
105 | |||
106 | continue; |
||
107 | } |
||
108 | |||
109 | if (!is_array($tRef) || ($tItem[2] & self::OVERWRITE) === self::OVERWRITE) { |
||
110 | $tRef = []; // initialize as an empty array |
||
111 | } |
||
112 | |||
113 | foreach ($tItem[1] as $tKey => $tSubnode) { |
||
114 | $tFlags = $tItem[2]; |
||
115 | $tListNode = false; |
||
116 | |||
117 | $tNodeParts = explode("|", $tKey); |
||
118 | $tNodeKey = array_shift($tNodeParts); |
||
119 | |||
120 | if ($tItem[5] && is_numeric($tNodeKey)) { |
||
121 | $tNodeKey = count($tRef); |
||
122 | } |
||
123 | |||
124 | foreach ($tNodeParts as $tNodePart) { |
||
125 | if (array_key_exists($tNodePart, $this->configFlags)) { |
||
126 | if ($this->configFlags[$tNodePart] !== true) { |
||
127 | continue 2; |
||
128 | } |
||
129 | } elseif ($tNodePart === "list") { |
||
130 | $tListNode = true; |
||
131 | } elseif ($tNodePart === "important") { |
||
132 | $tFlags |= self::OVERWRITE; |
||
133 | } elseif ($tNodePart === "flat") { |
||
134 | $tFlags |= self::FLATTEN; |
||
135 | } |
||
136 | } |
||
137 | |||
138 | $tNewNodeKey = $tItem[0]; |
||
139 | if (($tFlags & self::FLATTEN) === self::FLATTEN) { |
||
140 | $tNodeKey = ltrim("{$tItem[4]}/{$tNodeKey}", "/"); |
||
141 | $tNewNodeKey[] = $tNodeKey; |
||
142 | |||
143 | $tQueue[] = [$tNewNodeKey, $tSubnode, $tFlags, &$tRef, $tNodeKey, $tListNode]; |
||
144 | } else { |
||
145 | $tNewNodeKey[] = $tNodeKey; |
||
146 | $tQueue[] = [$tNewNodeKey, $tSubnode, $tFlags, &$tRef[$tNodeKey], null, $tListNode]; |
||
147 | } |
||
148 | } |
||
149 | } while (count($tQueue) > 0); |
||
150 | } |
||
151 | } |
||
152 |