Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 4 | class __TwigTemplate_6176cc1d70865f1c372391bee7ea89c10a999e56953e3bd41cdecc0c6a3f3921 extends Twig_Template |
||
| 5 | { |
||
| 6 | public function __construct(Twig_Environment $env) |
||
| 7 | { |
||
| 8 | parent::__construct($env); |
||
| 9 | |||
| 10 | $this->parent = false; |
||
| 11 | |||
| 12 | $this->blocks = array( |
||
| 13 | ); |
||
| 14 | } |
||
| 15 | |||
| 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 | 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 | |||
| 59 | public function getTemplateName() |
||
| 60 | { |
||
| 61 | return "opensearch.twig"; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function isTraitable() |
||
| 65 | { |
||
| 66 | return false; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function getDebugInfo() |
||
| 70 | { |
||
| 71 | return array ( 49 => 10, 43 => 8, 41 => 7, 37 => 6, 31 => 5, 25 => 4, 21 => 2, 19 => 1,); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | /* {% if project.config('base_url') -%}*/ |
||
| 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.