TenantAtlas/apps/platform/app/Support/Operations/Reconciliation/OperationRunReconciliationRegistry.php

47 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Operations\Reconciliation;
final class OperationRunReconciliationRegistry
{
public function __construct(
private readonly RestoreExecuteReconciliationAdapter $restoreExecuteAdapter,
private readonly EnvironmentReviewComposeReconciliationAdapter $environmentReviewComposeAdapter,
) {}
/**
* @return array<int, OperationRunReconciliationAdapter>
*/
public function all(): array
{
return [
$this->restoreExecuteAdapter,
$this->environmentReviewComposeAdapter,
];
}
/**
* @return array<int, string>
*/
public function supportedTypes(): array
{
return array_values(array_unique(array_merge(
$this->restoreExecuteAdapter->supportedTypes(),
$this->environmentReviewComposeAdapter->supportedTypes(),
)));
}
public function forType(string $type): ?OperationRunReconciliationAdapter
{
foreach ($this->all() as $adapter) {
if ($adapter->supportsType($type)) {
return $adapter;
}
}
return null;
}
}