You've already forked Atomcms-edit
f5666c104d
- Add DiagnosticRunner integration to Commandocentrum for system health display - Refactor EmulatorUpdateService from 2524 lines to 395 lines (facade pattern) - Extract EmulatorStatusService, EmulatorJarService, EmulatorSourceService - Extract EmulatorBuildService, EmulatorSqlService, EmulatorBackupService - Add shared EmulatorConfiguration trait for dependency injection - Preserve backward compatibility on all public methods
58 lines
1.3 KiB
PHP
Executable File
58 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Services\Diagnostics;
|
|
|
|
class DiagnosticRunner
|
|
{
|
|
/**
|
|
* @var array<DiagnosticResult>
|
|
*/
|
|
private array $results = [];
|
|
|
|
/**
|
|
* @return array<DiagnosticResult>
|
|
*/
|
|
public function runAll(): array
|
|
{
|
|
$this->results = [];
|
|
|
|
$diagnostics = [
|
|
new DatabaseDiagnostic(),
|
|
new SecurityDiagnostic(),
|
|
new SystemDiagnostic(),
|
|
new HttpDiagnostic(),
|
|
];
|
|
|
|
foreach ($diagnostics as $diagnostic) {
|
|
$this->results = array_merge($this->results, $diagnostic->runAll());
|
|
}
|
|
|
|
return $this->results;
|
|
}
|
|
|
|
public function hasErrors(): bool
|
|
{
|
|
return array_any($this->results, fn ($r) => $r->status === 'error');
|
|
}
|
|
|
|
public function hasWarnings(): bool
|
|
{
|
|
return array_any($this->results, fn ($r) => $r->status === 'warning');
|
|
}
|
|
|
|
public function getErrors(): array
|
|
{
|
|
return array_filter($this->results, fn ($r) => $r->status === 'error');
|
|
}
|
|
|
|
public function getWarnings(): array
|
|
{
|
|
return array_filter($this->results, fn ($r) => $r->status === 'warning');
|
|
}
|
|
|
|
public function getOk(): array
|
|
{
|
|
return array_filter($this->results, fn ($r) => $r->status === 'ok');
|
|
}
|
|
}
|