-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a
scrutiny:check-probes
artisan command
- Loading branch information
Showing
4 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Scrutiny\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Scrutiny\CheckProbes; | ||
use Scrutiny\CheckProbesResult; | ||
|
||
class CheckProbesCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'scrutiny:check-probes'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Check the Scrutiny probes'; | ||
|
||
public function handle(CheckProbes $checkProbes) | ||
{ | ||
/** @var CheckProbesResult $result */ | ||
$result = $checkProbes->handle(true)->first(); | ||
|
||
$this->line(''); | ||
$this->line($result->pluck('icon')->implode(' ')); | ||
$this->info("*** {$result->passed()->count()} passed ***"); | ||
|
||
$failed = $result->failed(); | ||
if ($failed->count() > 0) { | ||
$this->line(''); | ||
$this->error("*** {$failed->count()} failed ***"); | ||
|
||
$this->table( | ||
['Probe', 'Message'], | ||
$failed->map(function ($value) { | ||
return [ | ||
$value['name'], | ||
$value['message'] | ||
]; | ||
}) | ||
); | ||
} | ||
|
||
$skipped = $result->skipped(); | ||
if ($skipped->count() > 0) { | ||
$this->line(''); | ||
$this->warn("*** {$skipped->count()} skipped ***"); | ||
|
||
$this->table( | ||
['Probe', 'Message'], | ||
$skipped->map(function ($value) { | ||
return [ | ||
$value['name'], | ||
$value['message'] | ||
]; | ||
}) | ||
); | ||
} | ||
|
||
$this->line(''); | ||
|
||
return $failed->count() ? 1 : 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters