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 |
||
| 3 | class EcommerceProductVariationTaskDeleteAll extends BuildTask |
||
|
|
|||
| 4 | { |
||
| 5 | protected $title = "Deletes all the variations and associated data"; |
||
| 6 | |||
| 7 | protected $description = "Deletes ALL variations and all associated data, careful."; |
||
| 8 | |||
| 9 | protected $tableArray = array( |
||
| 10 | "ProductVariation", |
||
| 11 | "ProductVariation_AttributeValues", |
||
| 12 | "Product_VariationAttributes", |
||
| 13 | "ProductAttributeType", |
||
| 14 | "ProductAttributeValue" |
||
| 15 | ); |
||
| 16 | |||
| 17 | public function run($request) |
||
| 46 | } |
||
| 47 | |||
| 67 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.