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 namespace Comodojo\Extender\Utils; |
||
| 28 | class ProcessTools { |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Terminate a process |
||
| 32 | * |
||
| 33 | * @return bool |
||
| 34 | */ |
||
| 35 | public static function term($pid, $lagger_timeout = 0) { |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Kill a process |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | public static function kill($pid) { |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Return true if process is still running, false otherwise |
||
| 64 | * |
||
| 65 | * @return bool |
||
| 66 | */ |
||
| 67 | public static function isRunning($pid) { |
||
| 72 | |||
| 73 | public static function getNiceness($pid = null) { |
||
| 78 | |||
| 79 | public static function setNiceness($niceness = null, $pid = null) { |
||
| 92 | |||
| 93 | View Code Duplication | public static function filterNiceness($niceness=null) { |
|
| 104 | |||
| 105 | public static function getPid() { |
||
| 110 | |||
| 111 | } |
||
| 112 |
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.