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 | View Code Duplication | class __TwigTemplate_e51cc397ba0a43944b0e8928aca8497177a67ece595d0f5a46355a16ab788be2 extends Twig_Template |
|
5 | { |
||
6 | public function __construct(Twig_Environment $env) |
||
18 | |||
19 | protected function doGetParent(array $context) |
||
23 | |||
24 | protected function doDisplay(array $context, array $blocks = array()) |
||
31 | |||
32 | // line 3 |
||
33 | public function block_title($context, array $blocks = array()) |
||
38 | |||
39 | // line 4 |
||
40 | public function block_body_class($context, array $blocks = array()) |
||
44 | |||
45 | // line 6 |
||
46 | public function block_page_content($context, array $blocks = array()) |
||
59 | |||
60 | public function getTemplateName() |
||
64 | |||
65 | public function isTraitable() |
||
69 | |||
70 | public function getDebugInfo() |
||
74 | } |
||
75 | /* {% extends "layout/layout.twig" %}*/ |
||
88 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.