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 AddShipResponse extends AbstractStructBase |
|
|
|||
21 | { |
||
22 | /** |
||
23 | * The addShipResult |
||
24 | * Meta informations extracted from the WSDL |
||
25 | * - maxOccurs: 1 |
||
26 | * - minOccurs: 0 |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | public $addShipResult; |
||
31 | |||
32 | /** |
||
33 | * Constructor method for addShipResponse |
||
34 | * |
||
35 | * @uses AddShipResponse::setAddShipResult() |
||
36 | * |
||
37 | * @param string $addShipResult |
||
38 | */ |
||
39 | public function __construct($addShipResult = null) |
||
44 | |||
45 | /** |
||
46 | * Get addShipResult value |
||
47 | * |
||
48 | * @return string|null |
||
49 | */ |
||
50 | public function getAddShipResult() |
||
54 | |||
55 | /** |
||
56 | * Set addShipResult value |
||
57 | * |
||
58 | * @param string $addShipResult |
||
59 | * |
||
60 | * @return \Alhoqbani\SmsaWebService\Soap\Type\AddShipResponse |
||
61 | */ |
||
62 | public function setAddShipResult($addShipResult = 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\AddShipResponse |
||
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.