<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Services\Descriptor;

use PpPhp\Core\Platform\Services\Contracts\DescriptorInterface;

final class ServiceDescriptor implements DescriptorInterface
{
    public function __construct(
        private readonly string $id,
        private readonly string $label,
        private readonly string $version = '1.0.0',
        private readonly string $type = 'service',
        private readonly string $description = '',
        private readonly array $dependencies = [],
        private readonly array $capabilities = [],
        private readonly array $aliases = [],
        private readonly array $tags = [],
        private readonly string $lifecycle = 'singleton',
        private readonly string $visibility = 'public',
        private readonly bool $lazy = true,
        private readonly array $metadata = [],
        private readonly string $source = ''
    ) {
    }

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

    public function type(): string
    {
        return $this->type;
    }

    public function label(): string
    {
        return $this->label;
    }

    public function version(): string
    {
        return $this->version;
    }

    public function description(): string
    {
        return $this->description;
    }

    public function dependencies(): array
    {
        return $this->dependencies;
    }

    public function capabilities(): array
    {
        return $this->capabilities;
    }

    public function aliases(): array
    {
        return $this->aliases;
    }

    public function tags(): array
    {
        return $this->tags;
    }

    public function lifecycle(): string
    {
        return $this->lifecycle;
    }

    public function visibility(): string
    {
        return $this->visibility;
    }

    public function lazy(): bool
    {
        return $this->lazy;
    }

    public function metadata(): array
    {
        return $this->metadata;
    }

    public function source(): string
    {
        return $this->source;
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'type' => $this->type,
            'label' => $this->label,
            'version' => $this->version,
            'description' => $this->description,
            'dependencies' => $this->dependencies,
            'capabilities' => $this->capabilities,
            'aliases' => $this->aliases,
            'tags' => $this->tags,
            'lifecycle' => $this->lifecycle,
            'visibility' => $this->visibility,
            'lazy' => $this->lazy,
            'metadata' => $this->metadata,
            'source' => $this->source,
        ];
    }
}
