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 | class ArrayOfOrderLineItem extends AbstractStructArrayBase |
||
21 | { |
||
22 | /** |
||
23 | * The OrderLineItem |
||
24 | * Meta informations extracted from the WSDL |
||
25 | * - maxOccurs: unbounded |
||
26 | * - minOccurs: 0 |
||
27 | * - nillable: true |
||
28 | * |
||
29 | * @var \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem[] |
||
30 | */ |
||
31 | public $OrderLineItem; |
||
32 | |||
33 | /** |
||
34 | * Constructor method for ArrayOfOrderLineItem |
||
35 | * |
||
36 | * @uses ArrayOfOrderLineItem::setOrderLineItem() |
||
37 | * |
||
38 | * @param \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem[] $orderLineItem |
||
39 | */ |
||
40 | public function __construct(array $orderLineItem = []) |
||
45 | |||
46 | /** |
||
47 | * Get OrderLineItem value |
||
48 | * An additional test has been added (isset) before returning the property value as |
||
49 | * this property may have been unset before, due to the fact that this property is |
||
50 | * removable from the request (nillable=true+minOccurs=0) |
||
51 | * |
||
52 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem[]|null |
||
53 | */ |
||
54 | public function getOrderLineItem() |
||
58 | |||
59 | /** |
||
60 | * Set OrderLineItem value |
||
61 | * This property is removable from request (nillable=true+minOccurs=0), therefore |
||
62 | * if the value assigned to this property is null, it is removed from this object |
||
63 | * |
||
64 | * @param \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem[] $orderLineItem |
||
65 | * |
||
66 | * @throws \InvalidArgumentException |
||
67 | * |
||
68 | * @return \Alhoqbani\SmsaWebService\Soap\Type\ArrayOfOrderLineItem |
||
69 | */ |
||
70 | public function setOrderLineItem(array $orderLineItem = []) |
||
86 | |||
87 | /** |
||
88 | * Add item to OrderLineItem value |
||
89 | * |
||
90 | * @param \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem $item |
||
91 | * |
||
92 | * @throws \InvalidArgumentException |
||
93 | * |
||
94 | * @return \Alhoqbani\SmsaWebService\Soap\Type\ArrayOfOrderLineItem |
||
95 | */ |
||
96 | public function addToOrderLineItem(\Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem $item) |
||
106 | |||
107 | /** |
||
108 | * Returns the current element |
||
109 | * |
||
110 | * @see AbstractStructArrayBase::current() |
||
111 | * |
||
112 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem|null |
||
113 | */ |
||
114 | public function current() |
||
118 | |||
119 | /** |
||
120 | * Returns the indexed element |
||
121 | * |
||
122 | * @see AbstractStructArrayBase::item() |
||
123 | * |
||
124 | * @param int $index |
||
125 | * |
||
126 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem|null |
||
127 | */ |
||
128 | public function item($index) |
||
132 | |||
133 | /** |
||
134 | * Returns the first element |
||
135 | * |
||
136 | * @see AbstractStructArrayBase::first() |
||
137 | * |
||
138 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem|null |
||
139 | */ |
||
140 | public function first() |
||
144 | |||
145 | /** |
||
146 | * Returns the last element |
||
147 | * |
||
148 | * @see AbstractStructArrayBase::last() |
||
149 | * |
||
150 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem|null |
||
151 | */ |
||
152 | public function last() |
||
156 | |||
157 | /** |
||
158 | * Returns the element at the offset |
||
159 | * |
||
160 | * @see AbstractStructArrayBase::offsetGet() |
||
161 | * |
||
162 | * @param int $offset |
||
163 | * |
||
164 | * @return \Alhoqbani\SmsaWebService\Soap\Type\OrderLineItem|null |
||
165 | */ |
||
166 | public function offsetGet($offset) |
||
170 | |||
171 | /** |
||
172 | * Returns the attribute name |
||
173 | * |
||
174 | * @see AbstractStructArrayBase::getAttributeName() |
||
175 | * |
||
176 | * @return string OrderLineItem |
||
177 | */ |
||
178 | public function getAttributeName() |
||
182 | |||
183 | /** |
||
184 | * Method called when an object has been exported with var_export() functions |
||
185 | * It allows to return an object instantiated with the values |
||
186 | * |
||
187 | * @see AbstractStructArrayBase::__set_state() |
||
188 | * |
||
189 | * @uses AbstractStructArrayBase::__set_state() |
||
190 | * |
||
191 | * @param array $array the exported values |
||
192 | * |
||
193 | * @return \Alhoqbani\SmsaWebService\Soap\Type\ArrayOfOrderLineItem |
||
194 | */ |
||
195 | public static function __set_state(array $array) |
||
199 | |||
200 | /** |
||
201 | * Method returning the class name |
||
202 | * |
||
203 | * @return string __CLASS__ |
||
204 | */ |
||
205 | public function __toString() |
||
209 | } |
||
210 |
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.