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 |
||
| 15 | class WorkflowFieldTransitionController extends RequestHandler |
||
| 16 | { |
||
| 17 | private static $url_handlers = array( |
||
|
|
|||
| 18 | 'new/$ParentID!' => 'handleAdd', |
||
| 19 | 'item/$ID!' => 'handleItem' |
||
| 20 | ); |
||
| 21 | |||
| 22 | private static $allowed_actions = array( |
||
| 23 | 'handleAdd', |
||
| 24 | 'handleItem' |
||
| 25 | ); |
||
| 26 | |||
| 27 | protected $parent; |
||
| 28 | protected $name; |
||
| 29 | |||
| 30 | public function __construct($parent, $name) |
||
| 37 | |||
| 38 | public function handleAdd() |
||
| 56 | |||
| 57 | View Code Duplication | public function handleItem() |
|
| 72 | |||
| 73 | public function RootField() |
||
| 77 | |||
| 78 | public function Link($action = null) |
||
| 82 | } |
||
| 83 |