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 |
||
19 | class Row extends Nette\Object |
||
|
|||
20 | 1 | { |
|
21 | |||
22 | /** |
||
23 | * @var DataGrid |
||
24 | */ |
||
25 | protected $datagrid; |
||
26 | |||
27 | /** |
||
28 | * @var mixed |
||
29 | */ |
||
30 | protected $item; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $primary_key; |
||
36 | |||
37 | /** |
||
38 | * @var mixed |
||
39 | */ |
||
40 | protected $id; |
||
41 | |||
42 | /** |
||
43 | * @var Html |
||
44 | */ |
||
45 | protected $control; |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @param DataGrid $datagrid |
||
50 | * @param mixed $item |
||
51 | * @param string $primary_key |
||
52 | */ |
||
53 | public function __construct(DataGrid $datagrid, $item, $primary_key) |
||
65 | 1 | ||
66 | |||
67 | /** |
||
68 | * Get id value of item |
||
69 | * @return mixed |
||
70 | */ |
||
71 | public function getId() |
||
75 | |||
76 | |||
77 | /** |
||
78 | * Get item value of key |
||
79 | * @param mixed $key |
||
80 | * @return mixed |
||
81 | */ |
||
82 | public function getValue($key) |
||
107 | 1 | ||
108 | |||
109 | /** |
||
110 | * @return Html |
||
111 | */ |
||
112 | public function getControl() |
||
116 | |||
117 | |||
118 | 1 | /** |
|
119 | * @return string |
||
120 | */ |
||
121 | public function getControlClass() |
||
129 | |||
130 | |||
131 | 1 | /** |
|
132 | * @param ActiveRow $item |
||
133 | * @param string $key |
||
134 | * @return mixed|NULL |
||
135 | */ |
||
136 | public function getActiveRowProperty(ActiveRow $item, $key) |
||
160 | |||
161 | |||
162 | /** |
||
163 | * LeanMapper: Access object properties to get a item value |
||
164 | * @param LeanMapper\Entity $item |
||
165 | * @param mixed $key |
||
166 | * @return mixed |
||
167 | */ |
||
168 | public function getLeanMapperEntityProperty(LeanMapper\Entity $item, $key) |
||
190 | |||
191 | |||
192 | 1 | /** |
|
193 | * Doctrine: Access object properties to get a item value |
||
194 | * @param mixed $item |
||
195 | * @param mixed $key |
||
196 | * @return mixed |
||
197 | */ |
||
198 | public function getDoctrineEntityProperty($item, $key) |
||
221 | |||
222 | |||
223 | /** |
||
224 | * Get original item |
||
225 | * @return mixed |
||
226 | */ |
||
227 | public function getItem() |
||
231 | |||
232 | |||
233 | /** |
||
234 | 1 | * Has particular row group actions allowed? |
|
235 | 1 | * @return bool |
|
236 | 1 | */ |
|
237 | public function hasGroupAction() |
||
243 | |||
244 | |||
245 | /** |
||
246 | * Has particular row a action allowed? |
||
247 | * @param mixed $key |
||
248 | * @return bool |
||
249 | */ |
||
250 | 1 | public function hasAction($key) |
|
256 | |||
257 | |||
258 | /** |
||
259 | * Has particular row inlie edit allowed? |
||
260 | * @return bool |
||
261 | */ |
||
262 | public function hasInlineEdit() |
||
268 | |||
269 | |||
270 | /** |
||
271 | * @param string $key |
||
272 | * @param Column\Column $column |
||
273 | * @return void |
||
274 | */ |
||
275 | public function applyColumnCallback($key, Column\Column $column) |
||
285 | |||
286 | |||
287 | /** |
||
288 | * Key may contain ".", get rid of it (+ the table alias) |
||
289 | * |
||
290 | * @param string $key |
||
291 | * @return string |
||
292 | */ |
||
293 | private function formatDibiRowKey($key) |
||
301 | |||
302 | } |
||
303 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.