<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Kernel\Facades;

use PpPhp\Core\Platform\Kernel\Platform;
use PpPhp\Core\Platform\Services\Definition\ServiceDefinition;

final class Registry
{
    public static function register(ServiceDefinition $definition): void
    {
        Platform::registries()->services->register($definition);
    }

    public static function has(string $id): bool
    {
        return Platform::registries()->services->has($id);
    }

    public static function get(string $id): ?ServiceDefinition
    {
        return Platform::registries()->services->get($id);
    }

    public static function all(): array
    {
        return Platform::registries()->services->all();
    }

    public static function alias(string $alias, string $target): void
    {
        Platform::registries()->aliases->register($alias, $target);
    }

    public static function resolve(string $id): string
    {
        return Platform::registries()->aliases->resolve($id);
    }

    public static function aliases(): array
    {
        return Platform::registries()->aliases->all();
    }
}
