Conditions | 29 |
Paths | 21 |
Total Lines | 112 |
Code Lines | 70 |
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 |
||
46 | public function block_page_content($context, array $blocks = array()) |
||
47 | { |
||
48 | // line 7 |
||
49 | echo " |
||
50 | <div class=\"page-header\"> |
||
51 | <h1>Index</h1> |
||
52 | </div> |
||
53 | |||
54 | <ul class=\"pagination\"> |
||
55 | "; |
||
56 | // line 13 |
||
57 | $context['_parent'] = $context; |
||
58 | $context['_seq'] = twig_ensure_traversable(range("A", "Z")); |
||
59 | foreach ($context['_seq'] as $context["_key"] => $context["letter"]) { |
||
60 | // line 14 |
||
61 | echo " "; |
||
62 | if (($this->getAttribute((isset($context["items"]) ? $context["items"] : null), $context["letter"], array(), "array", true, true) && (twig_length_filter($this->env, $this->getAttribute((isset($context["items"]) ? $context["items"] : $this->getContext($context, "items")), $context["letter"], array(), "array")) > 1))) { |
||
63 | // line 15 |
||
64 | echo " <li><a href=\"#letter"; |
||
65 | echo $context["letter"]; |
||
66 | echo "\">"; |
||
67 | echo $context["letter"]; |
||
68 | echo "</a></li> |
||
69 | "; |
||
70 | } else { |
||
71 | // line 17 |
||
72 | echo " <li class=\"disabled\"><a href=\"#letter"; |
||
73 | echo $context["letter"]; |
||
74 | echo "\">"; |
||
75 | echo $context["letter"]; |
||
76 | echo "</a></li> |
||
77 | "; |
||
78 | } |
||
79 | // line 19 |
||
80 | echo " "; |
||
81 | } |
||
82 | $_parent = $context['_parent']; |
||
83 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['letter'], $context['_parent'], $context['loop']); |
||
84 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
85 | // line 20 |
||
86 | echo " </ul> |
||
87 | |||
88 | "; |
||
89 | // line 22 |
||
90 | $context['_parent'] = $context; |
||
91 | $context['_seq'] = twig_ensure_traversable((isset($context["items"]) ? $context["items"] : $this->getContext($context, "items"))); |
||
92 | foreach ($context['_seq'] as $context["letter"] => $context["elements"]) { |
||
93 | // line 23 |
||
94 | echo "<h2 id=\"letter"; |
||
95 | echo $context["letter"]; |
||
96 | echo "\">"; |
||
97 | echo $context["letter"]; |
||
98 | echo "</h2> |
||
99 | <dl id=\"index\">"; |
||
100 | // line 25 |
||
101 | $context['_parent'] = $context; |
||
102 | $context['_seq'] = twig_ensure_traversable($context["elements"]); |
||
103 | foreach ($context['_seq'] as $context["_key"] => $context["element"]) { |
||
104 | // line 26 |
||
105 | $context["type"] = $this->getAttribute($context["element"], 0, array(), "array"); |
||
106 | // line 27 |
||
107 | $context["value"] = $this->getAttribute($context["element"], 1, array(), "array"); |
||
108 | // line 28 |
||
109 | if (("class" == (isset($context["type"]) ? $context["type"] : $this->getContext($context, "type")))) { |
||
110 | // line 29 |
||
111 | echo "<dt>"; |
||
112 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getclass_link((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value"))); |
||
113 | if ((isset($context["has_namespaces"]) ? $context["has_namespaces"] : $this->getContext($context, "has_namespaces"))) { |
||
114 | echo " — <em>Class in namespace "; |
||
115 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getnamespace_link($this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "namespace", array())); |
||
116 | } |
||
117 | echo "</em></dt> |
||
118 | <dd>"; |
||
119 | // line 30 |
||
120 | echo $this->env->getExtension('sami')->parseDesc($context, $this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "shortdesc", array()), (isset($context["value"]) ? $context["value"] : $this->getContext($context, "value"))); |
||
121 | echo "</dd>"; |
||
122 | } elseif (("method" == // line 31 |
||
123 | (isset($context["type"]) ? $context["type"] : $this->getContext($context, "type")))) { |
||
124 | // line 32 |
||
125 | echo "<dt>"; |
||
126 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getmethod_link((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value"))); |
||
127 | echo "() — <em>Method in class "; |
||
128 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getclass_link($this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "class", array())); |
||
129 | echo "</em></dt> |
||
130 | <dd>"; |
||
131 | // line 33 |
||
132 | echo $this->env->getExtension('sami')->parseDesc($context, $this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "shortdesc", array()), $this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "class", array())); |
||
133 | echo "</dd>"; |
||
134 | } elseif (("property" == // line 34 |
||
135 | (isset($context["type"]) ? $context["type"] : $this->getContext($context, "type")))) { |
||
136 | // line 35 |
||
137 | echo "<dt>\$"; |
||
138 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getproperty_link((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value"))); |
||
139 | echo " — <em>Property in class "; |
||
140 | echo $context["__internal_31b6f5ef213cef65beaa17c48a7aece0e09df5bb8bd8a41d0aecf511f824fc11"]->getclass_link($this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "class", array())); |
||
141 | echo "</em></dt> |
||
142 | <dd>"; |
||
143 | // line 36 |
||
144 | echo $this->env->getExtension('sami')->parseDesc($context, $this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "shortdesc", array()), $this->getAttribute((isset($context["value"]) ? $context["value"] : $this->getContext($context, "value")), "class", array())); |
||
145 | echo "</dd>"; |
||
146 | } |
||
147 | } |
||
148 | $_parent = $context['_parent']; |
||
149 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['element'], $context['_parent'], $context['loop']); |
||
150 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
151 | // line 39 |
||
152 | echo " </dl>"; |
||
153 | } |
||
154 | $_parent = $context['_parent']; |
||
155 | unset($context['_seq'], $context['_iterated'], $context['letter'], $context['elements'], $context['_parent'], $context['loop']); |
||
156 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
157 | } |
||
158 | |||
216 |
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.