Conditions | 13 |
Paths | 3 |
Total Lines | 42 |
Code Lines | 20 |
Lines | 7 |
Ratio | 16.67 % |
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 |
||
16 | protected function doDisplay(array $context, array $blocks = array()) |
||
17 | { |
||
18 | // line 1 |
||
19 | if ($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "base_url"), "method")) { |
||
20 | // line 2 |
||
21 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> |
||
22 | <OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\" xmlns:referrer=\"http://a9.com/-/opensearch/extensions/referrer/\"> |
||
23 | <ShortName>"; |
||
24 | // line 4 |
||
25 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "title"), "method"), "html", null, true); |
||
26 | echo " ("; |
||
27 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "version", array()), "html", null, true); |
||
28 | echo ")</ShortName> |
||
29 | <Description>Searches "; |
||
30 | // line 5 |
||
31 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "title"), "method"), "html", null, true); |
||
32 | echo " ("; |
||
33 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "version", array()), "html", null, true); |
||
34 | echo ")</Description> |
||
35 | <Tags>"; |
||
36 | // line 6 |
||
37 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "title"), "method"), "html", null, true); |
||
38 | echo "</Tags> |
||
39 | "; |
||
40 | // line 7 |
||
41 | View Code Duplication | if ($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "favicon"), "method")) { |
|
42 | // line 8 |
||
43 | echo "<Image height=\"16\" width=\"16\" type=\"image/x-icon\">"; |
||
44 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "favicon"), "method"), "html", null, true); |
||
45 | echo "</Image> |
||
46 | "; |
||
47 | } |
||
48 | // line 10 |
||
49 | echo " <Url type=\"text/html\" method=\"GET\" template=\""; |
||
50 | echo twig_escape_filter($this->env, (twig_replace_filter($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "base_url"), "method"), array("%version%" => $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "version", array()))) . "/index.html?q={searchTerms}&src={referrer:source?}"), "html", null, true); |
||
51 | echo "\"/> |
||
52 | <InputEncoding>UTF-8</InputEncoding> |
||
53 | <AdultContent>false</AdultContent> |
||
54 | </OpenSearchDescription> |
||
55 | "; |
||
56 | } |
||
57 | } |
||
58 | |||
89 |
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.