<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Compatibility\Adapters;

use PpPhp\Core\Platform\Compatibility\CompatibilityAdapter;
use PpPhp\Core\Platform\Services\Definition\ServiceDefinition;
use PpPhp\Core\Platform\Services\Registry\RegistryCollection;

final class LegacyRegistryAdapter extends CompatibilityAdapter
{
    public function __construct(private readonly RegistryCollection $registries)
    {
        parent::__construct('legacy-registry-adapter', 'core/Registry', 'core/Platform/Services/Registry', 'active');
    }

    public function registerService(ServiceDefinition $definition): void { $this->registries->services->register($definition); }
    public function hasService(string $id): bool { return $this->registries->services->has($id); }
    public function getService(string $id): ?ServiceDefinition { return $this->registries->services->get($id); }
    public function services(): array { return $this->registries->services->all(); }
}
