<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\Enums;

use BackedEnum;
use Filament\Support\Colors\Color;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasIcon;
use Filament\Support\Contracts\HasLabel;
use Filament\Support\Icons\Heroicon;
use Illuminate\Contracts\Support\Htmlable;
use TechnoArtisan\FilamentCms\Traits\EnumValuesToArray;

enum PhpType: string implements HasLabel, HasColor , HasIcon
{
    use EnumValuesToArray;

    case BOOLEAN = 'boolean';
    case INTEGER = 'integer';
    case FLOAT   = 'float';
    case STRING  = 'string';
    case ARRAY   = 'array';
    case OBJECT  = 'object';
    case NULL    = 'null';

    public function getLabel(): string|Htmlable|null
    {
        return match ($this) {
            self::BOOLEAN => 'Boolean',
            self::INTEGER => 'Integer',
            self::FLOAT   => 'Float',
            self::STRING  => 'String',
            self::ARRAY   => 'Array',
            self::OBJECT  => 'Object',
            self::NULL    => 'NULL',
        };
    }

    public function getColor(): string|array|null
    {
        return match ($this) {
            self::BOOLEAN => Color::Amber,
            self::INTEGER => Color::Purple,
            self::FLOAT   => Color::Pink,
            self::STRING  => Color::Green,
            self::ARRAY   => Color::Blue,
            self::OBJECT  => Color::Red,
            self::NULL    => Color::Slate,
        };
    }

    public function getIcon(): string|null|BackedEnum
    {
        return match ($this) {
            self::BOOLEAN => Heroicon::tryFrom('stop-circle'),
            self::INTEGER => Heroicon::tryFrom('numbered-list'),
            self::FLOAT   => Heroicon::tryFrom('cube-transparent'),
            self::STRING  => Heroicon::tryFrom('document-text'),
            self::ARRAY   => Heroicon::tryFrom('square-3-stack-3d'),
            self::OBJECT  => Heroicon::tryFrom('home-modern'),
            self::NULL    => Heroicon::tryFrom('arrow-down-on-square'),
        };
    }
}
