45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Support\Verification\VerificationReportSanitizer;
|
|
use App\Support\Verification\VerificationReportSchema;
|
|
|
|
final class VerificationReportViewer
|
|
{
|
|
/**
|
|
* @return array<string, mixed>|null
|
|
*/
|
|
public static function report(OperationRun $run): ?array
|
|
{
|
|
$context = is_array($run->context) ? $run->context : [];
|
|
$report = $context['verification_report'] ?? null;
|
|
|
|
if (! is_array($report)) {
|
|
return null;
|
|
}
|
|
|
|
$report = VerificationReportSanitizer::sanitizeReport($report);
|
|
|
|
if (! VerificationReportSchema::isValidReport($report)) {
|
|
return null;
|
|
}
|
|
|
|
return $report;
|
|
}
|
|
|
|
public static function shouldRenderForRun(OperationRun $run): bool
|
|
{
|
|
$context = is_array($run->context) ? $run->context : [];
|
|
|
|
if (array_key_exists('verification_report', $context)) {
|
|
return true;
|
|
}
|
|
|
|
return in_array((string) $run->type, ['provider.connection.check'], true);
|
|
}
|
|
}
|