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 Select_Field extends Predefined_Options_Field { |
||
| 11 | /** |
||
| 12 | * Sets either the select has a nice UI |
||
| 13 | * |
||
| 14 | * @var boolean |
||
| 15 | */ |
||
| 16 | protected $has_ui = false; |
||
| 17 | |||
| 18 | public function set_has_ui( $state ) { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritDoc} |
||
| 26 | */ |
||
| 27 | public function set_value_from_input( $input ) { |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritDoc} |
||
| 48 | */ |
||
| 49 | View Code Duplication | public function to_json( $load ) { |
|
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritDoc} |
||
| 66 | */ |
||
| 67 | public function get_formatted_value() { |
||
| 79 | } |
||
| 80 |