Files
git-contribution-graph/src/Service/Provider/ProviderHealthChecker.php
T
haylanandClaude Sonnet 4.6 2f3268c0b7 refactor: reorganise Service/ into Provider/ and Renderer/ sub-namespaces
Move all provider-related classes, enums, interface and trait into
App\Service\Provider; move SvgRenderer into App\Service\Renderer.
ContributionAggregator stays at the Service root as the orchestrator.
Test namespaces and use statements updated to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 00:10:09 +02:00

40 lines
974 B
PHP

<?php
declare(strict_types=1);
namespace App\Service\Provider;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
final class ProviderHealthChecker
{
public function __construct(
#[AutowireIterator('app.provider')]
private readonly iterable $providers,
) {}
/**
* @return array{status: string, providers: array<string, array<string, string>>}
*/
public function check(): array
{
$statuses = [];
$hasError = false;
/** @var ProviderInterface $provider */
foreach ($this->providers as $provider) {
$status = $provider->probe();
$statuses[$status->name] = $status->toArray();
if ($status->status === ProviderStatusType::Error) {
$hasError = true;
}
}
return [
'status' => $hasError ? 'degraded' : 'ok',
'providers' => $statuses,
];
}
}