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 BlockCollection extends Collection |
||
|
|||
21 | { |
||
22 | |||
23 | /** |
||
24 | * Collection constructor |
||
25 | * |
||
26 | * @throws InvalidInterfaceException |
||
27 | */ |
||
28 | public function __construct() |
||
32 | |||
33 | |||
34 | /** |
||
35 | * unRegisterBlock |
||
36 | * finds block in the Collection based on the identifier that was set using addObject() |
||
37 | * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
||
38 | * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
||
39 | * |
||
40 | * @param mixed $identifier |
||
41 | * @return boolean |
||
42 | */ |
||
43 | View Code Duplication | public function unRegisterBlock($identifier) |
|
56 | |||
57 | |||
58 | /** |
||
59 | * unRegisterAllBlocks |
||
60 | * calls unRegisterBlock() on all blocks in Collection. |
||
61 | * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function unRegisterAllBlocks() |
||
74 | } |
||
75 |