| Conditions | 11 |
| Paths | 32 |
| Total Lines | 37 |
| Code Lines | 19 |
| 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 |
||
| 50 | public function handle() |
||
| 51 | { |
||
| 52 | $resources = collect($this->argument('resources')); |
||
| 53 | |||
| 54 | $resourcesIsEmpty = $resources->isEmpty(); |
||
| 55 | |||
| 56 | $this->line( |
||
| 57 | $this->timeMessage() |
||
| 58 | ); |
||
| 59 | |||
| 60 | if ($resources->contains('cpu') || $resourcesIsEmpty) { |
||
| 61 | $this->info( |
||
| 62 | $this->cpuMessage($this->cpu->check()) |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($resources->contains('memory') || $resourcesIsEmpty) { |
||
| 67 | $this->info( |
||
| 68 | $this->memoryMessage($this->memory->check()) |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | |||
| 72 | if ($resources->contains('network') || $resourcesIsEmpty) { |
||
| 73 | $this->info( |
||
| 74 | $this->networkMessage($this->network->check()) |
||
| 75 | ); |
||
| 76 | } |
||
| 77 | |||
| 78 | if ($resources->contains('web-server') || $resourcesIsEmpty) { |
||
| 79 | $this->info( |
||
| 80 | $this->webServerMessage($this->webServer->check()) |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | |||
| 84 | if ($resources->contains('hdd') || $resourcesIsEmpty) { |
||
| 85 | $this->info( |
||
| 86 | $this->storageMessage($this->storage->check()) |
||
| 87 | ); |
||
| 91 |