<?php

namespace App\Domain\Accounting\Enums;

/** Period control (§46). */
enum PeriodStatus: string
{
    case Open = 'open';
    case Closed = 'closed';
    case Locked = 'locked';

    public function label(): string
    {
        return match ($this) {
            self::Open => 'Open',
            self::Closed => 'Closed',
            self::Locked => 'Locked',
        };
    }

    public function acceptsPostings(): bool
    {
        return $this === self::Open;
    }

    /** A closed period can be reopened; a locked one is sealed. */
    public function canReopen(): bool
    {
        return $this === self::Closed;
    }

    /** @return array<int, string> */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
