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 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
18 | View Code Duplication | class EE_Extra_Join extends EE_Base_Class { |
|
|
|||
19 | |||
20 | /** |
||
21 | * @param array $props_n_values |
||
22 | * @param null $timezone |
||
23 | * @return EE_Extra_Join|mixed |
||
24 | */ |
||
25 | public static function new_instance( $props_n_values = array(), $timezone = NULL ) { |
||
29 | |||
30 | |||
31 | |||
32 | /** |
||
33 | * @param array $props_n_values |
||
34 | * @param null $timezone |
||
35 | * @return EE_Extra_Join |
||
36 | */ |
||
37 | public static function new_instance_from_db ( $props_n_values = array(), $timezone = NULL ) { |
||
40 | |||
41 | } |
||
42 | //end class EE_Extra_Join |
||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.