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_38b46a007d69fcaef63805d5b1e5e1a6f5cc8171abc60d1a4639698b2792a1e2 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 (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 1, $this->getSourceContext()); })()), "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, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 4, $this->getSourceContext()); })()), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 26 | echo " ("; |
||
| 27 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 4, $this->getSourceContext()); })()), "version", array()), "html", null, true); |
||
| 28 | echo ")</ShortName> |
||
| 29 | <Description>Searches "; |
||
| 30 | // line 5 |
||
| 31 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 5, $this->getSourceContext()); })()), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 32 | echo " ("; |
||
| 33 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 5, $this->getSourceContext()); })()), "version", array()), "html", null, true); |
||
| 34 | echo ")</Description> |
||
| 35 | <Tags>"; |
||
| 36 | // line 6 |
||
| 37 | echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 6, $this->getSourceContext()); })()), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 38 | echo "</Tags> |
||
| 39 | "; |
||
| 40 | // line 7 |
||
| 41 | if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 7, $this->getSourceContext()); })()), "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, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 8, $this->getSourceContext()); })()), "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(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 10, $this->getSourceContext()); })()), "config", array(0 => "base_url"), "method"), array("%version%" => twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 10, $this->getSourceContext()); })()), "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 | public function getSourceContext() |
||
| 75 | { |
||
| 76 | return new Twig_Source("{% if project.config('base_url') -%} |
||
| 77 | <?xml version=\"1.0\" encoding=\"UTF-8\"?> |
||
| 78 | <OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\" xmlns:referrer=\"http://a9.com/-/opensearch/extensions/referrer/\"> |
||
| 79 | <ShortName>{{ project.config('title') }} ({{ project.version }})</ShortName> |
||
| 80 | <Description>Searches {{ project.config('title') }} ({{ project.version }})</Description> |
||
| 81 | <Tags>{{ project.config('title') }}</Tags> |
||
| 82 | {% if project.config('favicon') -%} |
||
| 83 | <Image height=\"16\" width=\"16\" type=\"image/x-icon\">{{ project.config('favicon') }}</Image> |
||
| 84 | {% endif %} |
||
| 85 | <Url type=\"text/html\" method=\"GET\" template=\"{{ project.config('base_url')|replace({'%version%': project.version}) ~ '/index.html?q={searchTerms}&src={referrer:source?}' }}\"/> |
||
| 86 | <InputEncoding>UTF-8</InputEncoding> |
||
| 87 | <AdultContent>false</AdultContent> |
||
| 88 | </OpenSearchDescription> |
||
| 89 | {% endif %} |
||
| 90 | ", "opensearch.twig", "phar:///Users/bobby/Dropbox/Sites/OpenSource/Slackify/sami.phar/Sami/Resources/themes/default/opensearch.twig"); |
||
| 91 | } |
||
| 92 | } |
||
| 93 |