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 |
||
20 | View Code Duplication | class GetStatusByRefResponse extends AbstractStructBase |
|
|
|||
21 | { |
||
22 | /** |
||
23 | * The getStatusByRefResult |
||
24 | * Meta informations extracted from the WSDL |
||
25 | * - maxOccurs: 1 |
||
26 | * - minOccurs: 0 |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | public $getStatusByRefResult; |
||
31 | |||
32 | /** |
||
33 | * Constructor method for getStatusByRefResponse |
||
34 | * |
||
35 | * @uses GetStatusByRefResponse::setGetStatusByRefResult() |
||
36 | * |
||
37 | * @param string $getStatusByRefResult |
||
38 | */ |
||
39 | public function __construct($getStatusByRefResult = null) |
||
44 | |||
45 | /** |
||
46 | * Get getStatusByRefResult value |
||
47 | * |
||
48 | * @return string|null |
||
49 | */ |
||
50 | public function getGetStatusByRefResult() |
||
54 | |||
55 | /** |
||
56 | * Set getStatusByRefResult value |
||
57 | * |
||
58 | * @param string $getStatusByRefResult |
||
59 | * |
||
60 | * @return \Alhoqbani\SmsaWebService\Soap\Type\GetStatusByRefResponse |
||
61 | */ |
||
62 | public function setGetStatusByRefResult($getStatusByRefResult = null) |
||
72 | |||
73 | /** |
||
74 | * Method called when an object has been exported with var_export() functions |
||
75 | * It allows to return an object instantiated with the values |
||
76 | * |
||
77 | * @see AbstractStructBase::__set_state() |
||
78 | * |
||
79 | * @uses AbstractStructBase::__set_state() |
||
80 | * |
||
81 | * @param array $array the exported values |
||
82 | * |
||
83 | * @return \Alhoqbani\SmsaWebService\Soap\Type\GetStatusByRefResponse |
||
84 | */ |
||
85 | public static function __set_state(array $array) |
||
89 | |||
90 | /** |
||
91 | * Method returning the class name |
||
92 | * |
||
93 | * @return string __CLASS__ |
||
94 | */ |
||
95 | public function __toString() |
||
99 | } |
||
100 |
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.