<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Services\Container;

use PpPhp\Core\Platform\Services\Registry\RegistryCollection;

final class PlatformServiceHub
{
    public function __construct(
        private readonly RegistryCollection $registries,
        private readonly ServiceContainer $container
    ) {
    }

    public function registries(): RegistryCollection
    {
        return $this->registries;
    }

    public function container(): ServiceContainer
    {
        return $this->container;
    }

    public function has(string $id): bool
    {
        return $this->container->has($id);
    }

    public function get(string $id): object
    {
        return $this->container->get($id);
    }

    public function toArray(): array
    {
        return [
            'registries' => $this->registries->toArray(),
            'instances' => array_keys($this->container->instances()),
        ];
    }
}
