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 |
||
23 | final class VerificationResult |
||
24 | { |
||
25 | /** |
||
26 | * @var boolean |
||
27 | */ |
||
28 | private $verificationSucceeded; |
||
29 | |||
30 | /** |
||
31 | * @var string|null |
||
32 | */ |
||
33 | private $procedureId; |
||
34 | |||
35 | /** |
||
36 | * @param string $procedureId |
||
37 | * @return VerificationResult |
||
38 | */ |
||
39 | View Code Duplication | public static function verificationSucceeded($procedureId) |
|
51 | |||
52 | public static function noSuchProcedure() |
||
59 | |||
60 | /** |
||
61 | * @param string $procedureId |
||
62 | * @return VerificationResult |
||
63 | */ |
||
64 | View Code Duplication | public static function verificationFailed($procedureId) |
|
76 | |||
77 | /** |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isSuccess() |
||
84 | |||
85 | /** |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function didVerificationSucceed() |
||
92 | |||
93 | /** |
||
94 | * @return null|string NULL if no procedure ID was known for given SAML request ID. |
||
95 | */ |
||
96 | public function getProcedureId() |
||
100 | } |
||
101 |
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.