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 |
||
| 26 | class PgHstore extends ArrayTypeConverter |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * @see \Pomm\Converter\ConverterInterface |
||
| 30 | */ |
||
| 31 | public function fromPg($data, $type, Session $session) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @see \Pomm\Converter\ConverterInterface |
||
| 49 | */ |
||
| 50 | View Code Duplication | public function toPg($data, $type, Session $session) |
|
| 58 | |||
| 59 | /** |
||
| 60 | * @see \Pomm\Converter\ConverterInterface |
||
| 61 | */ |
||
| 62 | View Code Duplication | public function toPgStandardFormat($data, $type, Session $session) |
|
| 70 | |||
| 71 | /** |
||
| 72 | * buildArray |
||
| 73 | * |
||
| 74 | * Return an array of HStore elements. |
||
| 75 | * |
||
| 76 | * @access protected |
||
| 77 | * @param array $data |
||
| 78 | * @return array |
||
| 79 | */ |
||
| 80 | protected function buildArray(array $data) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * escape |
||
| 101 | * |
||
| 102 | * Escape a string. |
||
| 103 | * |
||
| 104 | * @access protected |
||
| 105 | * @param string $string |
||
| 106 | * @return string |
||
| 107 | */ |
||
| 108 | protected function escape($string) |
||
| 116 | } |
||
| 117 |