Conditions | 14 |
Paths | 9 |
Total Lines | 29 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
114 | public static function escapeCellFormat($cellFormat) |
||
115 | { |
||
116 | $ignoreUntil = ''; |
||
117 | $escaped = ''; |
||
118 | for ($i = 0, $ix = strlen($cellFormat); $i < $ix; $i++) { |
||
119 | $c = $cellFormat[$i]; |
||
120 | if ($ignoreUntil == '' && $c == '[') { |
||
121 | $ignoreUntil = ']'; |
||
122 | } else { |
||
123 | if ($ignoreUntil == '' && $c == '"') { |
||
124 | $ignoreUntil = '"'; |
||
125 | } else { |
||
126 | if ($ignoreUntil == $c) { |
||
127 | $ignoreUntil = ''; |
||
128 | } |
||
129 | } |
||
130 | } |
||
131 | if ($ignoreUntil == '' && |
||
132 | ($c == ' ' || $c == '-' || $c == '(' || $c == ')') && |
||
133 | ($i == 0 || $cellFormat[$i - 1] != '_') |
||
134 | ) { |
||
135 | $escaped .= "\\".$c; |
||
136 | } else { |
||
137 | $escaped .= $c; |
||
138 | } |
||
139 | } |
||
140 | |||
141 | return $escaped; |
||
142 | } |
||
143 | } |
||
144 |