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 |
||
12 | class Pool extends \PHPDaemon\Network\Server |
||
13 | { |
||
14 | /** |
||
15 | * @var string Variables order "GPC" |
||
16 | */ |
||
17 | public $variablesOrder; |
||
18 | |||
19 | /** |
||
20 | * @var WebSocketServer WebSocketServer instance |
||
21 | */ |
||
22 | public $WS; |
||
23 | |||
24 | /** |
||
25 | * Called when worker is going to update configuration. |
||
26 | * @return void |
||
27 | */ |
||
28 | View Code Duplication | public function onConfigUpdated() |
|
38 | |||
39 | /** |
||
40 | * Called when the worker is ready to go. |
||
41 | * @return void |
||
42 | */ |
||
43 | public function onReady() |
||
48 | |||
49 | /** |
||
50 | * Setting default config options |
||
51 | * Overriden from AppInstance::getConfigDefaults |
||
52 | * @return array|bool |
||
53 | */ |
||
54 | View Code Duplication | protected function getConfigDefaults() |
|
100 | } |
||
101 |
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.