| Total Complexity | 8 |
| Total Lines | 60 |
| Duplicated Lines | 21.67 % |
| Coverage | 68.42% |
| Changes | 0 | ||
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 |
||
| 19 | class DownWAMP extends Command |
||
| 20 | { |
||
| 21 | const SERVER_PID_FILE = 'servers.pids'; |
||
| 22 | const CLIENT_PID_FILE = 'clients.pids'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | */ |
||
| 27 | protected $signature = 'wamp:stop {--server-only} {--client-only}'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | protected $description = 'Stop all background running server & clients |
||
| 33 | {--server-only : Stop only running server instances} |
||
| 34 | {--client-only : Stop only running client instances} |
||
| 35 | '; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Handle command |
||
| 39 | * |
||
| 40 | * @author Donii Sergii <[email protected]> |
||
| 41 | */ |
||
| 42 | 2 | public function fire() |
|
| 43 | { |
||
| 44 | 2 | $clientsOnly = $this->option('client-only'); |
|
| 45 | 2 | $serversOnly = $this->option('server-only'); |
|
| 46 | |||
| 47 | 2 | if (!$serversOnly) { |
|
| 48 | 1 | $this->stopInstances(storage_path(self::CLIENT_PID_FILE)); |
|
|
|
|||
| 49 | } |
||
| 50 | |||
| 51 | 2 | if (!$clientsOnly) { |
|
| 52 | 1 | $this->stopInstances(storage_path(self::SERVER_PID_FILE)); |
|
| 53 | } |
||
| 54 | 2 | } |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Handle command alias |
||
| 58 | * |
||
| 59 | * @author Donii Sergii <[email protected]> |
||
| 60 | */ |
||
| 61 | 2 | public function handle() |
|
| 64 | 2 | } |
|
| 65 | |||
| 66 | 2 | View Code Duplication | private function stopInstances($file) |
| 82 |