You've already forked Atomcms-edit
refactor: integrate diagnostics into Commandocentrum and split EmulatorUpdateService
- 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
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user