56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Support\SchoolYear;
|
|
|
|
final class SchoolYearContext
|
|
{
|
|
public function __construct(
|
|
private readonly int $id,
|
|
private readonly string $yearName,
|
|
private readonly string $status,
|
|
private readonly bool $explicitSelection = false,
|
|
) {
|
|
}
|
|
|
|
public function id(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function yearName(): string
|
|
{
|
|
return $this->yearName;
|
|
}
|
|
|
|
public function status(): string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function isActive(): bool
|
|
{
|
|
return $this->status === 'active';
|
|
}
|
|
|
|
public function isReadonly(): bool
|
|
{
|
|
return in_array($this->status, ['closed', 'archived'], true);
|
|
}
|
|
|
|
public function isExplicitSelection(): bool
|
|
{
|
|
return $this->explicitSelection;
|
|
}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->yearName,
|
|
'status' => $this->status,
|
|
'readonly' => $this->isReadonly(),
|
|
'explicitSelection' => $this->explicitSelection,
|
|
];
|
|
}
|
|
}
|