| Conditions | 10 |
| Paths | 12 |
| Total Lines | 38 |
| Code Lines | 26 |
| 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 |
||
| 54 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
||
| 55 | { |
||
| 56 | // check and get attributes |
||
| 57 | $_attr = $this->getAttributes($compiler, $args); |
||
| 58 | if ($_attr[ 'nocache' ] === true) { |
||
| 59 | $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
||
| 60 | } |
||
| 61 | if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
||
| 62 | $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
||
| 63 | } |
||
| 64 | // add code to initialize inheritance |
||
| 65 | $this->registerInit($compiler, true); |
||
| 66 | $file = trim($_attr[ 'file' ], '\'"'); |
||
| 67 | if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
||
| 68 | // generate code for each template |
||
| 69 | $files = array_reverse(explode('|', substr($file, 8))); |
||
| 70 | $i = 0; |
||
| 71 | foreach ($files as $file) { |
||
| 72 | if ($file[ 0 ] == '"') { |
||
| 73 | $file = trim($file, '".'); |
||
| 74 | } else { |
||
| 75 | $file = "'{$file}'"; |
||
| 76 | } |
||
| 77 | $i ++; |
||
| 78 | if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
||
| 79 | $this->compileEndChild($compiler); |
||
| 80 | } |
||
| 81 | $this->compileInclude($compiler, $file); |
||
| 82 | } |
||
| 83 | if (!isset($_attr[ 'extends_resource' ])) { |
||
| 84 | $this->compileEndChild($compiler); |
||
| 85 | } |
||
| 86 | } else { |
||
| 87 | $this->compileEndChild($compiler, $_attr[ 'file' ]); |
||
| 88 | } |
||
| 89 | $compiler->has_code = false; |
||
| 90 | return ''; |
||
| 91 | } |
||
| 92 | |||
| 145 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.