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 |
||
| 10 | class UnpublishItemWorkflowAction extends WorkflowAction { |
||
|
|
|||
| 11 | |||
| 12 | private static $db = array( |
||
| 13 | 'UnpublishDelay' => 'Int' |
||
| 14 | ); |
||
| 15 | |||
| 16 | public static $icon = 'advancedworkflow/images/publish.png'; |
||
| 17 | |||
| 18 | public function execute(WorkflowInstance $workflow) { |
||
| 47 | |||
| 48 | View Code Duplication | public function getCMSFields() { |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Unpublish action allows a user who is currently assigned at this point of the workflow to |
||
| 68 | * |
||
| 69 | * @param DataObject $target |
||
| 70 | * @return bool |
||
| 71 | */ |
||
| 72 | public function canPublishTarget(DataObject $target) { |
||
| 75 | |||
| 76 | } |
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.