Conditions | 12 |
Paths | 64 |
Total Lines | 29 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | 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 |
||
47 | public function handle() |
||
48 | { |
||
49 | $resourceReports = []; |
||
50 | |||
51 | $cpuUsage = $this->cpu->check(); |
||
52 | $memoryUsage = $this->memory->check(); |
||
53 | $networkStatus = $this->network->check(); |
||
54 | $hardDiskFreeSpace = $this->hardDisk->check(); |
||
55 | $webServerStatuses = $this->webServer->check(); |
||
56 | |||
57 | if (config('stethoscope.monitorable_resources.cpu') && $cpuUsage > config(('stethoscope.thresholds.cpu'))) |
||
58 | $resourceReports['cpu'] = $cpuUsage; |
||
59 | |||
60 | if ($memoryUsage > config(('stethoscope.thresholds.memory')) && config('stethoscope.monitorable_resources.memory')) |
||
61 | $resourceReports['memory'] = $memoryUsage; |
||
62 | |||
63 | if ($networkStatus == 'false' && config('stethoscope.monitorable_resources.network')) |
||
64 | $resourceReports['network'] = $networkStatus; |
||
65 | |||
66 | if ($hardDiskFreeSpace < config(('stethoscope.thresholds.hard_disk')) && config('stethoscope.monitorable_resources.hard_disk')) |
||
67 | $resourceReports['hardDisk'] = $hardDiskFreeSpace; |
||
68 | |||
69 | if ($webServerStatuses != 'active' && config('stethoscope.monitorable_resources.web_server')) |
||
70 | $resourceReports['webServer'] = $webServerStatuses; |
||
71 | |||
72 | Record::record($resourceReports); |
||
73 | |||
74 | if (!empty($resourceReports)) |
||
75 | TroubleOccurred::dispatch($resourceReports); |
||
76 | } |
||
78 |