<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Manifest;

final class ManifestRecord
{
    public function __construct(
        private readonly string $id,
        private readonly string $type,
        private readonly string $label,
        private readonly string $version = '1.0.0',
        private readonly string $status = 'active',
        private readonly string $description = '',
        private readonly array $services = [],
        private readonly array $dependencies = [],
        private readonly array $capabilities = [],
        private readonly array $raw = [],
        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 status(): string { return $this->status; }
    public function description(): string { return $this->description; }
    public function services(): array { return $this->services; }
    public function dependencies(): array { return $this->dependencies; }
    public function capabilities(): array { return $this->capabilities; }
    public function raw(): array { return $this->raw; }
    public function source(): string { return $this->source; }

    public function enabled(): bool
    {
        return !in_array($this->status, ['disabled', 'inactive', 'archived'], true);
    }

    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'type' => $this->type,
            'label' => $this->label,
            'version' => $this->version,
            'status' => $this->status,
            'description' => $this->description,
            'services' => $this->services,
            'dependencies' => $this->dependencies,
            'capabilities' => $this->capabilities,
            'source' => $this->source,
            'raw' => $this->raw,
        ];
    }
}
