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 |
||
29 | trait GroupTrait |
||
30 | { |
||
31 | use AbstractTrait; |
||
32 | |||
33 | /** |
||
34 | * {@inheritDoc} |
||
35 | */ |
||
36 | public function group($col) |
||
44 | |||
45 | /** |
||
46 | * {@inheritDoc} |
||
47 | */ |
||
48 | public function groupDesc($col) |
||
52 | |||
53 | /** |
||
54 | * {@inheritDoc} |
||
55 | */ |
||
56 | public function groupTpl(/*# string */ $template, $col) |
||
60 | |||
61 | /** |
||
62 | * {@inheritDoc} |
||
63 | */ |
||
64 | public function groupRaw(/*# string */ $rawString) |
||
69 | |||
70 | /** |
||
71 | * real group by |
||
72 | * @param string|string[]|Template $col column[s] |
||
73 | * @param string $suffix ''|ASC|DESC |
||
74 | * @param bool $rawMode |
||
75 | * @return $this |
||
76 | * @access protected |
||
77 | */ |
||
78 | View Code Duplication | protected function realGroup( |
|
95 | |||
96 | /** |
||
97 | * Multitple groupbys |
||
98 | * |
||
99 | * @param array $cols |
||
100 | * @param string $suffix |
||
101 | * @access protected |
||
102 | */ |
||
103 | protected function multipleGroup(array $cols, /*# string */ $suffix) |
||
109 | |||
110 | /** |
||
111 | * Build GROUP BY |
||
112 | * |
||
113 | * @param string $prefix |
||
114 | * @param array $settings |
||
115 | * @return string |
||
116 | * @access protected |
||
117 | */ |
||
118 | protected function buildGroup( |
||
124 | } |
||
125 |