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