| Conditions | 16 |
| Paths | 4 |
| Total Lines | 66 |
| Code Lines | 28 |
| Lines | 7 |
| Ratio | 10.61 % |
| 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 |
||
| 22 | protected function doDisplay(array $context, array $blocks = array()) |
||
| 23 | { |
||
| 24 | // line 1 |
||
| 25 | echo "<!DOCTYPE html> |
||
| 26 | <html lang=\"en\"> |
||
| 27 | <head> |
||
| 28 | <meta charset=\"UTF-8\" /> |
||
| 29 | <meta name=\"robots\" content=\"index, follow, all\" /> |
||
| 30 | <title>"; |
||
| 31 | // line 6 |
||
| 32 | $this->displayBlock('title', $context, $blocks); |
||
| 33 | echo "</title> |
||
| 34 | |||
| 35 | "; |
||
| 36 | // line 8 |
||
| 37 | $this->displayBlock('head', $context, $blocks); |
||
| 38 | // line 20 |
||
| 39 | echo " |
||
| 40 | "; |
||
| 41 | // line 21 |
||
| 42 | View Code Duplication | if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 21, $this->getSourceContext()); })()), "config", array(0 => "favicon"), "method")) { |
|
| 43 | // line 22 |
||
| 44 | echo " <link rel=\"shortcut icon\" href=\""; |
||
| 45 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 22, $this->getSourceContext()); })()), "config", array(0 => "favicon"), "method"), "html", null, true); |
||
| 46 | echo "\" /> |
||
| 47 | "; |
||
| 48 | } |
||
| 49 | // line 24 |
||
| 50 | echo " |
||
| 51 | "; |
||
| 52 | // line 25 |
||
| 53 | if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 25, $this->getSourceContext()); })()), "config", array(0 => "base_url"), "method")) { |
||
| 54 | // line 26 |
||
| 55 | $context['_parent'] = $context; |
||
| 56 | $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 26, $this->getSourceContext()); })()), "versions", array())); |
||
| 57 | foreach ($context['_seq'] as $context["_key"] => $context["version"]) { |
||
| 58 | // line 27 |
||
| 59 | echo "<link rel=\"search\" |
||
| 60 | type=\"application/opensearchdescription+xml\" |
||
| 61 | href=\""; |
||
| 62 | // line 29 |
||
| 63 | echo twig_escape_filter($this->env, twig_replace_filter(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 29, $this->getSourceContext()); })()), "config", array(0 => "base_url"), "method"), array("%version%" => $context["version"])), "html", null, true); |
||
| 64 | echo "/opensearch.xml\" |
||
| 65 | title=\""; |
||
| 66 | // line 30 |
||
| 67 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 30, $this->getSourceContext()); })()), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 68 | echo " ("; |
||
| 69 | echo twig_escape_filter($this->env, $context["version"], "html", null, true); |
||
| 70 | echo ")\" /> |
||
| 71 | "; |
||
| 72 | } |
||
| 73 | $_parent = $context['_parent']; |
||
| 74 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['version'], $context['_parent'], $context['loop']); |
||
| 75 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
| 76 | } |
||
| 77 | // line 33 |
||
| 78 | echo "</head> |
||
| 79 | |||
| 80 | "; |
||
| 81 | // line 35 |
||
| 82 | $this->displayBlock('html', $context, $blocks); |
||
| 83 | // line 40 |
||
| 84 | echo " |
||
| 85 | </html> |
||
| 86 | "; |
||
| 87 | } |
||
| 88 | |||
| 229 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.