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 |
||
10 | class Point extends Field |
||
11 | { |
||
12 | /** |
||
13 | * {@inheritdoc} |
||
14 | */ |
||
15 | View Code Duplication | public function getSelectExpression($as = null) |
|
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | public function getValueExpression($mark) |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | public function dataFromDatabase($data) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function dataToDatabase($data) |
||
60 | |||
61 | /** |
||
62 | * Check whether the value is valid before save in the database |
||
63 | * |
||
64 | * @param mixed $data |
||
65 | * |
||
66 | * @return bool |
||
67 | */ |
||
68 | private static function isValid($data) |
||
80 | } |
||
81 |