Total Complexity | 8 |
Total Lines | 60 |
Duplicated Lines | 21.67 % |
Coverage | 100% |
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 | 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 | 4 | View Code Duplication | private function stopInstances($file) |
82 |
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.