| Total Complexity | 8 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
| 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 | 4 | public function fire() |
|
| 43 | { |
||
| 44 | 4 | $clientsOnly = $this->option('client-only'); |
|
| 45 | 4 | $serversOnly = $this->option('server-only'); |
|
| 46 | |||
| 47 | 4 | if (!$serversOnly) { |
|
| 48 | 3 | $this->stopInstances(storage_path(self::CLIENT_PID_FILE)); |
|
|
|
|||
| 49 | } |
||
| 50 | |||
| 51 | 4 | if (!$clientsOnly) { |
|
| 52 | 3 | $this->stopInstances(storage_path(self::SERVER_PID_FILE)); |
|
| 53 | } |
||
| 54 | 4 | } |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Handle command alias |
||
| 58 | * |
||
| 59 | * @author Donii Sergii <[email protected]> |
||
| 60 | */ |
||
| 61 | 4 | public function handle() |
|
| 64 | 4 | } |
|
| 65 | |||
| 66 | /** |
||
| 67 | * Stop all process by pids from file $file |
||
| 68 | * |
||
| 69 | * @param string $filename |
||
| 70 | * |
||
| 71 | * @author Donii Sergii <[email protected]> |
||
| 72 | */ |
||
| 73 | 4 | private function stopInstances($filename) |
|
| 86 | } |
||
| 87 | 4 | } |
|
| 89 |