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 |
||
| 8 | View Code Duplication | class CreditCheckStatusDokladEnum extends iDokladAbstractEnum |
|
|
|
|||
| 9 | { |
||
| 10 | const NOT_FOUND = 0; |
||
| 11 | |||
| 12 | const OK = 1; |
||
| 13 | |||
| 14 | const OK_WITH_WARNINGS = 2; |
||
| 15 | |||
| 16 | const RISK = 3; |
||
| 17 | |||
| 18 | const NOT_VERIFIED = 4; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @return bool |
||
| 22 | */ |
||
| 23 | public function isNotFound(): bool |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | public function isOk(): bool |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | public function isOkWithWarnings(): bool |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | public function isRisk(): bool |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | public function isNotVerified(): bool |
||
| 59 | } |
||
| 60 |
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.