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 |
||
15 | class Status { |
||
16 | /** |
||
17 | * Is Jetpack in development (offline) mode? |
||
18 | * |
||
19 | * @return bool Whether Jetpack's development mode is active. |
||
20 | */ |
||
21 | View Code Duplication | public function is_development_mode() { |
|
44 | |||
45 | /** |
||
46 | * Whether this is a system with a multiple networks. |
||
47 | * Implemented since there is no core is_multi_network function. |
||
48 | * Right now there is no way to tell which network is the dominant network on the system. |
||
49 | * |
||
50 | * @return boolean |
||
51 | */ |
||
52 | View Code Duplication | public function is_multi_network() { |
|
67 | |||
68 | /** |
||
69 | * Whether the current site is single user site. |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | View Code Duplication | public function is_single_user_site() { |
|
83 | } |
||
84 |