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 |
||
17 | class Purchases { |
||
18 | |||
19 | const OPTION_CACHE = 'jetpack_purchases'; |
||
20 | |||
21 | /** |
||
22 | * Return the purchases a site has made. |
||
23 | * |
||
24 | * @return mixed|false |
||
25 | */ |
||
26 | public function get() { |
||
36 | |||
37 | /** |
||
38 | * Fetches the sites purchases from WP.com and caches them in an option. |
||
39 | * |
||
40 | * @return bool|mixed |
||
41 | */ |
||
42 | public function get_from_wpcom() { |
||
66 | |||
67 | } |
||
68 |