| Conditions | 24 |
| Paths | 16 |
| Total Lines | 74 |
| Code Lines | 30 |
| Lines | 27 |
| Ratio | 36.49 % |
| 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 |
||
| 71 | public function block_page_content($context, array $blocks = array()) |
||
| 72 | { |
||
| 73 | // line 17 |
||
| 74 | echo " |
||
| 75 | <div class=\"page-header\"> |
||
| 76 | <h1>"; |
||
| 77 | // line 19 |
||
| 78 | echo (isset($context["namespace"]) || array_key_exists("namespace", $context) ? $context["namespace"] : (function () { throw new Twig_Error_Runtime('Variable "namespace" does not exist.', 19, $this->getSourceContext()); })()); |
||
| 79 | echo "</h1> |
||
| 80 | </div> |
||
| 81 | |||
| 82 | "; |
||
| 83 | // line 22 |
||
| 84 | if ((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 22, $this->getSourceContext()); })())) { |
||
| 85 | // line 23 |
||
| 86 | echo " <h2>Namespaces</h2> |
||
| 87 | <div class=\"namespace-list\"> |
||
| 88 | "; |
||
| 89 | // line 25 |
||
| 90 | $context['_parent'] = $context; |
||
| 91 | $context['_seq'] = twig_ensure_traversable((isset($context["subnamespaces"]) || array_key_exists("subnamespaces", $context) ? $context["subnamespaces"] : (function () { throw new Twig_Error_Runtime('Variable "subnamespaces" does not exist.', 25, $this->getSourceContext()); })())); |
||
| 92 | foreach ($context['_seq'] as $context["_key"] => $context["ns"]) { |
||
| 93 | echo $context["__internal_084c0a9b4751f3912921b1f087047d19c4c1f20b347dd6cee5246a93c0cb9eed"]->macro_namespace_link($context["ns"]); |
||
| 94 | } |
||
| 95 | $_parent = $context['_parent']; |
||
| 96 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['ns'], $context['_parent'], $context['loop']); |
||
| 97 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
| 98 | // line 26 |
||
| 99 | echo " </div> |
||
| 100 | "; |
||
| 101 | } |
||
| 102 | // line 28 |
||
| 103 | echo " |
||
| 104 | "; |
||
| 105 | // line 29 |
||
| 106 | View Code Duplication | if ((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 29, $this->getSourceContext()); })())) { |
|
| 107 | // line 30 |
||
| 108 | echo " <h2>Classes</h2> |
||
| 109 | "; |
||
| 110 | // line 31 |
||
| 111 | echo $context["__internal_084c0a9b4751f3912921b1f087047d19c4c1f20b347dd6cee5246a93c0cb9eed"]->macro_render_classes((isset($context["classes"]) || array_key_exists("classes", $context) ? $context["classes"] : (function () { throw new Twig_Error_Runtime('Variable "classes" does not exist.', 31, $this->getSourceContext()); })())); |
||
| 112 | echo " |
||
| 113 | "; |
||
| 114 | } |
||
| 115 | // line 33 |
||
| 116 | echo " |
||
| 117 | "; |
||
| 118 | // line 34 |
||
| 119 | View Code Duplication | if ((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 34, $this->getSourceContext()); })())) { |
|
| 120 | // line 35 |
||
| 121 | echo " <h2>Interfaces</h2> |
||
| 122 | "; |
||
| 123 | // line 36 |
||
| 124 | echo $context["__internal_084c0a9b4751f3912921b1f087047d19c4c1f20b347dd6cee5246a93c0cb9eed"]->macro_render_classes((isset($context["interfaces"]) || array_key_exists("interfaces", $context) ? $context["interfaces"] : (function () { throw new Twig_Error_Runtime('Variable "interfaces" does not exist.', 36, $this->getSourceContext()); })())); |
||
| 125 | echo " |
||
| 126 | "; |
||
| 127 | } |
||
| 128 | // line 38 |
||
| 129 | echo " |
||
| 130 | "; |
||
| 131 | // line 39 |
||
| 132 | View Code Duplication | if ((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 39, $this->getSourceContext()); })())) { |
|
| 133 | // line 40 |
||
| 134 | echo " <h2>Exceptions</h2> |
||
| 135 | "; |
||
| 136 | // line 41 |
||
| 137 | echo $context["__internal_084c0a9b4751f3912921b1f087047d19c4c1f20b347dd6cee5246a93c0cb9eed"]->macro_render_classes((isset($context["exceptions"]) || array_key_exists("exceptions", $context) ? $context["exceptions"] : (function () { throw new Twig_Error_Runtime('Variable "exceptions" does not exist.', 41, $this->getSourceContext()); })())); |
||
| 138 | echo " |
||
| 139 | "; |
||
| 140 | } |
||
| 141 | // line 43 |
||
| 142 | echo " |
||
| 143 | "; |
||
| 144 | } |
||
| 145 | |||
| 210 |
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.