<?php

namespace App\DTOs;

final readonly class GuideCardData
{
    public function __construct(
        public string $title,
        public string $description,
        public ?string $icon,
        public int $orderIndex = 0,
        public bool $isActive = true,
    ) {}

    /**
     * @param  array<string, mixed>  $data
     */
    public static function fromArray(array $data): self
    {
        return new self(
            title: $data['title'],
            description: $data['description'],
            icon: $data['icon'] ?? null,
            orderIndex: $data['order_index'] ?? 0,
            isActive: $data['is_active'] ?? true,
        );
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'title' => $this->title,
            'description' => $this->description,
            'icon' => $this->icon,
            'order_index' => $this->orderIndex,
            'is_active' => $this->isActive,
        ];
    }
}
