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 | public function setMarkupEngine(MarkupEngineManager $manager) |
||
| 27 | |||
| 28 | 1 | /// |
|
| 29 | // Permalink management |
||
| 30 | 1 | /// |
|
| 31 | |||
| 32 | 1 | /** |
|
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | public function handleSpecialRedirects() |
||
| 51 | |||
| 52 | /// |
||
| 53 | // Document body transformation |
||
| 54 | 7 | /// |
|
| 55 | |||
| 56 | 7 | /** |
|
| 57 | * @throws TemplateErrorInterface |
||
| 58 | 7 | * |
|
| 59 | 7 | * @return string |
|
| 60 | */ |
||
| 61 | 7 | public function getContent() |
|
| 77 | 6 | ||
| 78 | 1 | /** |
|
| 79 | 1 | * {@inheritdoc} |
|
| 80 | */ |
||
| 81 | 6 | View Code Duplication | public function createJail() |
| 93 | |||
| 94 | /** |
||
| 95 | * {@inheritdoc} |
||
| 96 | */ |
||
| 97 | 25 | 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.