Add professional PHPDoc (summary + @param/@return) to the remaining public methods that had none or only partial coverage: GraphController's actions, ContributionStore's accessors, SvgRenderer's render() and private helpers (with concrete array-shape annotations), ProbeTrait, ProviderHealthChecker, ProviderStatus, and the Contribution entity. Also adds the matching @return shapes on SvgRendererTest's data providers.
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace GitContributionGraph\Service\Provider;
|
|
|
|
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
|
|
|
final class ProviderHealthChecker
|
|
{
|
|
/** @param iterable<ProviderInterface> $providers */
|
|
public function __construct(
|
|
#[AutowireIterator('app.provider')]
|
|
private readonly iterable $providers,
|
|
) {}
|
|
|
|
/**
|
|
* Probes every configured provider and aggregates the results for the /health endpoint.
|
|
*
|
|
* @return array{status: string, providers: array<string, array<string, string>>} 'status' is
|
|
* "degraded" if any provider's probe() reported an error, otherwise "ok"
|
|
*/
|
|
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,
|
|
];
|
|
}
|
|
}
|