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 |
||
8 | class Paystack |
||
9 | { |
||
10 | public $secret_key; |
||
11 | public $use_guzzle = false; |
||
12 | public $fallback_to_file_get_contents = true; |
||
13 | const VERSION="2.1.15"; |
||
14 | |||
15 | 14 | public function __construct($secret_key) |
|
22 | |||
23 | 1 | public function useGuzzle() |
|
27 | |||
28 | public static function disableFileGetContentsFallback() |
||
32 | |||
33 | public static function enableFileGetContentsFallback() |
||
37 | |||
38 | 4 | public function __call($method, $args) |
|
45 | |||
46 | 1 | private function handlePlural($singular_form, $method, $args) |
|
56 | |||
57 | 3 | private function handleSingular($method, $args) |
|
67 | |||
68 | /** |
||
69 | * @deprecated |
||
70 | */ |
||
71 | public static function registerAutoloader() |
||
82 | |||
83 | 2 | public function __get($name) |
|
87 | } |
||
88 |
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.