<?php

namespace Modules\Accounts\Enums;

enum AccountTypeEnum: string
{
    case ASSET = 'Asset';
    case LIABILITY = 'Liability';
    case EQUITY = 'Equity';
    case INCOME = 'Income';
    case EXPENSE = 'Expense';

    public static function casesAsArray(): array
    {
        return array_map(fn(self $case) => $case->value, self::cases());
    }

    public function rootCode(): int
    {
        return match ($this) {
            self::ASSET => 10,
            self::LIABILITY => 20,
            self::EQUITY => 30,
            self::INCOME => 40,
            self::EXPENSE => 50,
        };
    }

    public function range(): array
    {
        return match ($this) {
            self::ASSET => [10, 19],
            self::LIABILITY => [20, 29],
            self::EQUITY => [30, 39],
            self::INCOME => [40, 49],
            self::EXPENSE => [50, 59],
        };
    }
    
    public function label(): string
    {
        return match ($this) {
            self::ASSET => 'Assets',
            self::LIABILITY => 'Liabilities',
            self::EQUITY => 'Equity',
            self::INCOME => 'Income',
            self::EXPENSE => 'Expenses',
        };
    }
}
