<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Runtime;

use PpPhp\Core\Platform\Services\Blueprint\BlueprintCollection;
use PpPhp\Core\Platform\Services\Container\PlatformServiceHub;
use PpPhp\Core\Platform\Services\Descriptor\DescriptorCollection;
use PpPhp\Core\Platform\Services\Registry\RegistryCollection;

final class PlatformRuntimeContext
{
    public function __construct(
        private readonly RuntimeConfiguration $configuration,
        private readonly RuntimeEnvironment $environment,
        private readonly RuntimeState $state,
        private readonly DescriptorCollection $descriptors,
        private readonly BlueprintCollection $blueprints,
        private readonly RegistryCollection $registries,
        private readonly PlatformServiceHub $services
    ) {
    }

    public function configuration(): RuntimeConfiguration
    {
        return $this->configuration;
    }

    public function environment(): RuntimeEnvironment
    {
        return $this->environment;
    }

    public function state(): RuntimeState
    {
        return $this->state;
    }

    public function descriptors(): DescriptorCollection
    {
        return $this->descriptors;
    }

    public function blueprints(): BlueprintCollection
    {
        return $this->blueprints;
    }

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

    public function services(): PlatformServiceHub
    {
        return $this->services;
    }

    public function toArray(): array
    {
        return [
            'configuration' => $this->configuration->toArray(),
            'environment' => $this->environment->toArray(),
            'state' => $this->state->toArray(),
            'descriptors' => $this->descriptors->toArray(),
            'blueprints' => $this->blueprints->toArray(),
            'registries' => $this->registries->toArray(),
            'services' => $this->services->toArray(),
        ];
    }
}
