<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Services\Metadata;

final class ServiceDependency
{
    public function __construct(
        private readonly string $id,
        private readonly bool $optional = false,
        private readonly string $version = '',
        private readonly array $metadata = []
    ) {
    }

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

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

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

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

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'optional' => $this->optional,
            'version' => $this->version,
            'metadata' => $this->metadata,
        ];
    }
}
