Conditions | 12 |
Paths | 64 |
Total Lines | 50 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
51 | public function handle() |
||
52 | { |
||
53 | $resources = collect($this->argument('resources')); |
||
54 | |||
55 | $resourcesIsEmpty = $resources->isEmpty(); |
||
56 | |||
57 | $logs = []; |
||
58 | $logs['signature'] = $this->signature; |
||
59 | |||
60 | $this->line( |
||
61 | $this->timeMessage() |
||
62 | ); |
||
63 | |||
64 | if ($resources->contains('cpu') || $resourcesIsEmpty) { |
||
65 | $logs['cpu'] = $this->cpu->check(); |
||
66 | $this->info( |
||
67 | $this->cpuMessage($logs['cpu']) |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | if ($resources->contains('memory') || $resourcesIsEmpty) { |
||
72 | $logs['memory'] = $this->memory->check(); |
||
73 | $this->info( |
||
74 | $this->memoryMessage($logs['memory']) |
||
75 | ); |
||
76 | } |
||
77 | |||
78 | if ($resources->contains('network') || $resourcesIsEmpty) { |
||
79 | $logs['network'] = $this->network->check(); |
||
80 | $this->info( |
||
81 | $this->networkMessage($logs['network']) |
||
82 | ); |
||
83 | } |
||
84 | |||
85 | if ($resources->contains('web-server') || $resourcesIsEmpty) { |
||
86 | $logs['webServer'] = $this->webServer->check(); |
||
87 | $this->info( |
||
88 | $this->webServerMessage($logs['webServer']) |
||
89 | ); |
||
90 | } |
||
91 | |||
92 | if ($resources->contains('storage') || $resourcesIsEmpty) { |
||
93 | $logs['storage'] = $this->storage->check(); |
||
94 | $this->info( |
||
95 | $this->storageMessage($logs['storage']) |
||
96 | ); |
||
97 | } |
||
98 | |||
99 | if ($this->option('notif')){ |
||
100 | TroubleOccurred::dispatch($logs); |
||
101 | } |
||
104 |