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 |
||
| 27 | abstract class ArrayTypeConverter implements ConverterInterface |
||
| 28 | { |
||
| 29 | protected $converters = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * checkArray |
||
| 33 | * |
||
| 34 | * Check if the data is an array. |
||
| 35 | * |
||
| 36 | * @access protected |
||
| 37 | * @param mixed $data |
||
| 38 | * @throws ConverterException |
||
| 39 | * @return array $data |
||
| 40 | */ |
||
| 41 | protected function checkArray($data) |
||
| 54 | |||
| 55 | /** |
||
| 56 | * getSubtypeConverter |
||
| 57 | * |
||
| 58 | * Since the arrays in PostgreSQL have the same subtype, it is useful to |
||
| 59 | * cache it here to avoid summoning the ClientHolder all the time. |
||
| 60 | * |
||
| 61 | * @access protected |
||
| 62 | * @param string $type |
||
| 63 | * @param Session $session |
||
| 64 | * @return ConverterInterface |
||
| 65 | */ |
||
| 66 | protected function getSubtypeConverter($type, Session $session) |
||
| 77 | } |
||
| 78 |