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 |
||
17 | class PageController implements \Anax\DI\IInjectionAware |
||
18 | { |
||
19 | use \Anax\DI\TInjectable; |
||
20 | |||
21 | /** |
||
22 | * Properties |
||
23 | */ |
||
24 | private $content; |
||
25 | private $urlPrefix; |
||
26 | |||
27 | /** |
||
28 | * Initialize the controller |
||
29 | * |
||
30 | * @return void |
||
31 | */ |
||
32 | View Code Duplication | public function initialize(){ |
|
41 | |||
42 | /** |
||
43 | * Index content - Redirect to startpage |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function indexAction(){ |
||
51 | |||
52 | /** |
||
53 | * Visit page made by database content |
||
54 | * |
||
55 | * @param string $url Select url to content |
||
56 | * @return void |
||
57 | */ |
||
58 | public function pageAction($url = null){ |
||
81 | |||
82 | /** |
||
83 | * Prepare page to show in view |
||
84 | * |
||
85 | * @param object $page Page information |
||
86 | * @return object $result Prepared page information |
||
87 | */ |
||
88 | 1 | public function preparePage($page = null){ |
|
111 | } |