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 |
||
| 14 | class LevelSounds |
||
|
|
|||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @param Player $player |
||
| 18 | * |
||
| 19 | * @return void |
||
| 20 | */ |
||
| 21 | View Code Duplication | public static function LevelUp(Player $player): void |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param Player $player |
||
| 32 | * |
||
| 33 | * @return void |
||
| 34 | */ |
||
| 35 | View Code Duplication | public static function Anvil(Player $player): void |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param Player $player |
||
| 45 | * |
||
| 46 | * @return void |
||
| 47 | */ |
||
| 48 | View Code Duplication | public static function Travle(Player $player): void |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @param Player $player |
||
| 58 | * |
||
| 59 | * @return void |
||
| 60 | */ |
||
| 61 | View Code Duplication | public static function EndPortalSpawn(Player $player): void |
|
| 68 | |||
| 69 | /** |
||
| 70 | * @param Player $player |
||
| 71 | * |
||
| 72 | * @return void |
||
| 73 | */ |
||
| 74 | View Code Duplication | public static function Portal(Player $player): void |
|
| 81 | |||
| 82 | /** |
||
| 83 | * @param Player $player |
||
| 84 | * |
||
| 85 | * @return void |
||
| 86 | */ |
||
| 87 | View Code Duplication | public static function Thunder(Player $player): void |
|
| 94 | |||
| 95 | /** |
||
| 96 | * @param Player $player |
||
| 97 | * |
||
| 98 | * @return void |
||
| 99 | */ |
||
| 100 | View Code Duplication | public static function Remedy(Player $player): void |
|
| 107 | |||
| 108 | /** |
||
| 109 | * @param Player $player |
||
| 110 | * |
||
| 111 | * @return void |
||
| 112 | */ |
||
| 113 | View Code Duplication | public static function Launch(Player $player): void |
|
| 120 | |||
| 121 | /** |
||
| 122 | * @param Player $player |
||
| 123 | * |
||
| 124 | * @return void |
||
| 125 | */ |
||
| 126 | View Code Duplication | public static function Blast(Player $player): void |
|
| 133 | |||
| 134 | /** |
||
| 135 | * @param Player $player |
||
| 136 | * |
||
| 137 | * @return void |
||
| 138 | */ |
||
| 139 | View Code Duplication | public static function LargeBlast(Player $player): void |
|
| 146 | |||
| 147 | /** |
||
| 148 | * @param Player $player |
||
| 149 | * |
||
| 150 | * @return void |
||
| 151 | */ |
||
| 152 | View Code Duplication | public static function Twinklt(Player $player): void |
|
| 159 | |||
| 160 | /** |
||
| 161 | * @param Player $player |
||
| 162 | */ |
||
| 163 | View Code Duplication | public static function NotePiano(Player $player): void |
|
| 170 | } |
||
| 171 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.