Files
alrahma_sunday_school/app/Support/SchoolYear/SchoolYearStatus.php
T
root feb1b29a32
Tests / PHPUnit (push) Failing after 1m19s
apply the school year concept
2026-07-14 00:59:00 -04:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Support\SchoolYear;
final class SchoolYearStatus
{
public const DRAFT = 'draft';
public const ACTIVE = 'active';
public const CLOSING = 'closing';
public const CLOSED = 'closed';
public const ARCHIVED = 'archived';
public const ALL = [
self::DRAFT,
self::ACTIVE,
self::CLOSING,
self::CLOSED,
self::ARCHIVED,
];
public const TRANSITIONS = [
self::DRAFT => [self::ACTIVE],
self::ACTIVE => [self::CLOSING],
self::CLOSING => [self::ACTIVE, self::CLOSED],
self::CLOSED => [self::ACTIVE, self::ARCHIVED],
self::ARCHIVED => [],
];
public static function canTransition(string $from, string $to): bool
{
return in_array($to, self::TRANSITIONS[$from] ?? [], true);
}
public static function isReadonly(string $status): bool
{
return self::isLifecycleMetadataLocked($status);
}
public static function isLifecycleMetadataLocked(string $status): bool
{
return in_array($status, [self::CLOSED, self::ARCHIVED], true);
}
}