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 |
||
27 | class ProtectPanRequest implements IProtectPanRequest |
||
28 | { |
||
29 | use TTopLevelPayload, TPayloadLogger; |
||
30 | |||
31 | /** @var string */ |
||
32 | protected $paymentAccountNumber; |
||
33 | /** @var string */ |
||
34 | protected $tenderClass; |
||
35 | /** @var array */ |
||
36 | protected $tenderClassEnum = [self::TENDER_CLASS_CC, self::TENDER_CLASS_PL_CC, self::TENDER_CLASS_SV,]; |
||
37 | |||
38 | /** |
||
39 | * @param IValidatorIterator |
||
40 | * @param ISchemaValidator |
||
41 | * @param IPayloadMap |
||
42 | * @param LoggerInterface |
||
43 | * @param IPayload |
||
44 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
45 | */ |
||
46 | public function __construct( |
||
63 | |||
64 | |||
65 | public function getPaymentAccountNumber() |
||
69 | |||
70 | public function setPaymentAccountNumber($paymentAccountNumber) |
||
75 | |||
76 | public function getTenderClass() |
||
80 | |||
81 | View Code Duplication | public function setTenderClass($tenderClass) |
|
94 | |||
95 | /** |
||
96 | * Serialize the various parts of the payload into XML strings and |
||
97 | * simply concatenate them together. |
||
98 | * @return string |
||
99 | */ |
||
100 | protected function serializeContents() |
||
105 | |||
106 | /** |
||
107 | * The XML namespace for the payload. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | protected function getXmlNamespace() |
||
115 | |||
116 | protected function getSchemaFile() |
||
120 | |||
121 | /** |
||
122 | * Return the name of the xml root node. |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | protected function getRootNodeName() |
||
130 | } |
||
131 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.