| Conditions | 34 | 
| Paths | 1156 | 
| Total Lines | 84 | 
| Code Lines | 76 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 7 | ||
| Bugs | 3 | 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  | 
            ||
| 142 |   function procLines() {
 | 
            ||
| 143 | /* @var $heir Tag[] Tag Heirachy Array */  | 
            ||
| 144 | $heir = array();  | 
            ||
| 145 |     while ($this->lineNo < $this->lineCount) {
 | 
            ||
| 146 | $line = $this->lines[$this->lineNo];  | 
            ||
| 147 |       if (trim($line)) if (preg_match(self::REGEX_PARSE_LINE, $line, $m)) {
 | 
            ||
| 148 | if (FALSE !== strpos($m[1], "\t"))  | 
            ||
| 149 |           throw new ParseError("Tabs are not supported in templates at this time");
 | 
            ||
| 150 | $indent = strlen($m[1]);  | 
            ||
| 151 | $tag = isset($m[2]) ? $tag = $m[2] : "";  | 
            ||
| 152 | $classid = isset($m[3]) ? $m[3] : "";  | 
            ||
| 153 |         $params = str_replace(array('\[', '\]', '\\&'), array('[', ']', '%26'), isset($m[4]) ? $m[4] : "");
 | 
            ||
| 154 | $textcode = isset($m[5]) ? $m[5] : "";  | 
            ||
| 155 | $text = isset($m[8]) ? $m[8] : "";  | 
            ||
| 156 | $code = isset($m[6]) ? $m[6] : "";  | 
            ||
| 157 | $i = self::indentLevel($indent);  | 
            ||
| 158 | unset($m[0]);  | 
            ||
| 159 |         switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) {
 | 
            ||
| 160 | case "|": //Control Tag  | 
            ||
| 161 | if ($code == "|snippet")  | 
            ||
| 162 | $hTag = new Tag\Snippet($text);  | 
            ||
| 163 | elseif ($code == "|form")  | 
            ||
| 164 | $hTag = new Tag\Form($text);  | 
            ||
| 165 | elseif ($code == "|formhint")  | 
            ||
| 166 | $hTag = new Tag\FormHint($text);  | 
            ||
| 167 |             elseif ($code == "|else") {
 | 
            ||
| 168 | $hTag = new Tag\Control(substr($code, 1), $heir[$i - 1]);  | 
            ||
| 169 | $hTag->setVar($text);  | 
            ||
| 170 |             } else {
 | 
            ||
| 171 | $hTag = new Tag\Control(substr($code, 1));  | 
            ||
| 172 | $hTag->setVar($text);  | 
            ||
| 173 | }  | 
            ||
| 174 | break;  | 
            ||
| 175 | case ":": //Filter Tag  | 
            ||
| 176 | $hTag = new Tag\Filter(substr($code, 1));  | 
            ||
| 177 | $hTag->addContent($text, Text::TOKEN_CODE);  | 
            ||
| 178 | foreach ($this->consumeBlock($indent) as $l)  | 
            ||
| 179 | $hTag->addContent($l, Text::TOKEN_CODE);  | 
            ||
| 180 | break;  | 
            ||
| 181 | case "_": //String Tag  | 
            ||
| 182 | case "__": //Unescape String Tag  | 
            ||
| 183 | $hTag = new Tag\Text($textcode);  | 
            ||
| 184 | $hTag->addContent($text);  | 
            ||
| 185 | break;  | 
            ||
| 186 | case "/": // HTML Comment  | 
            ||
| 187 | case "//": // Non Printed Comment  | 
            ||
| 188 | $hTag = new Tag\Comment($textcode);  | 
            ||
| 189 | $hTag->addContent($text);  | 
            ||
| 190 | foreach ($this->consumeBlock($indent) as $l)  | 
            ||
| 191 | $hTag->addContent($l, Text::TOKEN_CODE);  | 
            ||
| 192 | break;  | 
            ||
| 193 | default:  | 
            ||
| 194 | $attr = array();  | 
            ||
| 195 |             if(isset($params[0]) && $params[0] == "[") {
 | 
            ||
| 196 | $param = substr($params, 1, strlen($params) - 2);  | 
            ||
| 197 |               $param = str_replace('+','%2B', $param);
 | 
            ||
| 198 |               $param = str_replace('\\&','%26', $param);
 | 
            ||
| 199 | // parse_str($param, $attr);  | 
            ||
| 200 | $attr = $this->parseQueryString($param);  | 
            ||
| 201 | }  | 
            ||
| 202 | $class = array(); $id = ""; $ref = "";  | 
            ||
| 203 |             preg_match_all('/[#\.!][a-zA-Z0-9\-\_]+/m', $classid, $cid);
 | 
            ||
| 204 |             if (isset($cid[0])) foreach ($cid[0] as $s) {
 | 
            ||
| 205 | if ($s[0] == "#") $id = substr($s, 1);  | 
            ||
| 206 | if ($s[0] == ".") $class[] = substr($s, 1);  | 
            ||
| 207 | if ($s[0] == "!") $ref = substr($s, 1);  | 
            ||
| 208 | }  | 
            ||
| 209 | if($ref)  | 
            ||
| 210 | $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref);  | 
            ||
| 211 | else  | 
            ||
| 212 | $hTag = new Tag\Html($tag, $class, $attr, $id);  | 
            ||
| 213 | $hTag->addContent($text);  | 
            ||
| 214 | break;  | 
            ||
| 215 | }  | 
            ||
| 216 | $heir[$i] = $hTag;  | 
            ||
| 217 | if ($i > 0)  | 
            ||
| 218 | $heir[$i - 1]->addChild($hTag);  | 
            ||
| 219 | else  | 
            ||
| 220 | $this->root[] = $hTag;  | 
            ||
| 221 | } else  | 
            ||
| 222 |         throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error());
 | 
            ||
| 223 | $this->lineNo++;  | 
            ||
| 224 | }  | 
            ||
| 225 | }  | 
            ||
| 226 | |||
| 279 | 
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.