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 |
||
15 | class ContentItem extends PermalinkFrontMatterDocument implements CollectableItem, TemplateReadyDocument |
||
16 | { |
||
17 | use CollectableItemTrait; |
||
18 | use TemplateEngineDependent; |
||
19 | |||
20 | /** @var MarkupEngine */ |
||
21 | private $markupEngine; |
||
22 | |||
23 | 64 | public function setMarkupEngine(MarkupEngineManager $manager) |
|
27 | |||
28 | /// |
||
29 | // Permalink management |
||
30 | /// |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | 1 | public function handleSpecialRedirects() |
|
51 | |||
52 | /// |
||
53 | // Document body transformation |
||
54 | /// |
||
55 | |||
56 | /** |
||
57 | * @throws TemplateErrorInterface |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 7 | public function getContent() |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 25 | View Code Duplication | public function createJail() |
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | View Code Duplication | public function jsonSerialize() |
|
105 | } |
||
106 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.