<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Metadata\ValueObjects;

use PpPhp\Core\Platform\Metadata\Collections\PlatformTagCollection;

final class PlatformMetadata
{
    public function __construct(
        private readonly string $name,
        private readonly string $description,
        private readonly string $category,
        private readonly string $icon = '',
        private readonly string $author = 'PPphp Team',
        private readonly ?PlatformVersionInfo $version = null,
        private readonly ?PlatformTagCollection $tags = null
    ) {}

    public function name(): string
    {
        return $this->name;
    }
    public function description(): string
    {
        return $this->description;
    }
    public function category(): string
    {
        return $this->category;
    }
    public function icon(): string
    {
        return $this->icon;
    }
    public function author(): string
    {
        return $this->author;
    }
    public function version(): PlatformVersionInfo
    {
        return $this->version ?? new PlatformVersionInfo();
    }
    public function tags(): PlatformTagCollection
    {
        return $this->tags ?? new PlatformTagCollection();
    }

    public function toArray(): array
    {
        return [
            'name' => $this->name,
            'description' => $this->description,
            'category' => $this->category,
            'icon' => $this->icon,
            'author' => $this->author,
            'version' => $this->version()->toArray(),
            'tags' => $this->tags()->toArray(),
        ];
    }
}
