Conditions | 12 |
Paths | 2 |
Total Lines | 65 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
43 | public function block_page_content($context, array $blocks = array()) |
||
44 | { |
||
45 | // line 6 |
||
46 | echo " <div class=\"page-header\"> |
||
47 | <h1>Namespaces</h1> |
||
48 | </div> |
||
49 | |||
50 | "; |
||
51 | // line 10 |
||
52 | if ((isset($context["namespaces"]) ? $context["namespaces"] : $this->getContext($context, "namespaces"))) { |
||
53 | // line 11 |
||
54 | echo " <div class=\"namespaces clearfix\"> |
||
55 | "; |
||
56 | // line 12 |
||
57 | $context["last_name"] = ""; |
||
58 | // line 13 |
||
59 | echo " "; |
||
60 | $context['_parent'] = $context; |
||
61 | $context['_seq'] = twig_ensure_traversable((isset($context["namespaces"]) ? $context["namespaces"] : $this->getContext($context, "namespaces"))); |
||
62 | foreach ($context['_seq'] as $context["_key"] => $context["namespace"]) { |
||
63 | // line 14 |
||
64 | echo " "; |
||
65 | $context["top_level"] = twig_first($this->env, twig_split_filter($this->env, $context["namespace"], "\\")); |
||
66 | // line 15 |
||
67 | echo " "; |
||
68 | if (((isset($context["top_level"]) ? $context["top_level"] : $this->getContext($context, "top_level")) != (isset($context["last_name"]) ? $context["last_name"] : $this->getContext($context, "last_name")))) { |
||
69 | // line 16 |
||
70 | echo " "; |
||
71 | if ((isset($context["last_name"]) ? $context["last_name"] : $this->getContext($context, "last_name"))) { |
||
72 | echo "</ul></div>"; |
||
73 | } |
||
74 | // line 17 |
||
75 | echo " <div class=\"namespace-container\"> |
||
76 | <h2>"; |
||
77 | // line 18 |
||
78 | echo (isset($context["top_level"]) ? $context["top_level"] : $this->getContext($context, "top_level")); |
||
79 | echo "</h2> |
||
80 | <ul> |
||
81 | "; |
||
82 | // line 20 |
||
83 | $context["last_name"] = (isset($context["top_level"]) ? $context["top_level"] : $this->getContext($context, "top_level")); |
||
84 | // line 21 |
||
85 | echo " "; |
||
86 | } |
||
87 | // line 22 |
||
88 | echo " <li><a href=\""; |
||
89 | echo $this->env->getExtension('sami')->pathForNamespace($context, $context["namespace"]); |
||
90 | echo "\">"; |
||
91 | echo $context["namespace"]; |
||
92 | echo "</a></li> |
||
93 | "; |
||
94 | } |
||
95 | $_parent = $context['_parent']; |
||
96 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['namespace'], $context['_parent'], $context['loop']); |
||
97 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
98 | // line 24 |
||
99 | echo " </ul> |
||
100 | </div> |
||
101 | </div> |
||
102 | "; |
||
103 | } |
||
104 | // line 28 |
||
105 | echo " |
||
106 | "; |
||
107 | } |
||
108 | |||
154 |
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.