RunCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace EricMakesStuff\ServerMonitor\Commands;
4
5
use EricMakesStuff\ServerMonitor\Monitors\BaseMonitor;
6
use EricMakesStuff\ServerMonitor\Monitors\ServerMonitorFactory;
7
8
class RunCommand extends BaseCommand
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $signature = 'monitor:run {monitor? : Comma-delimited list of names of specific monitors to run}';
14
15
    /**
16
     * @var string
17
     */
18
    protected $description = 'Run all server monitor tasks.';
19
20
    public function handle()
21
    {
22
        $monitors = ServerMonitorFactory::createForMonitorConfig(
23
            config('server-monitor.monitors'),
24
            explode(',', $this->argument('monitor'))
25
        );
26
27
        $monitors->each(function (BaseMonitor $monitor) {
28
            $monitor->runMonitor();
29
        });
30
    }
31
}
32