Add invite-only registration mode

Support configurable on, invite-only, and off registration modes, including case-insensitive invitation checks and test coverage.
This commit is contained in:
Constantin Graf
2026-08-25 16:38:07 +02:00
committed by Constantin Graf
parent 3e36b1cc01
commit 3ec2abb309
7 changed files with 157 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Enums;
enum RegistrationMode: string
{
case On = 'on';
case InviteOnly = 'invite-only';
case Off = 'off';
public static function fromConfig(mixed $value): self
{
if ($value === true) {
return self::On;
}
if ($value === false || $value === null) {
return self::Off;
}
return match (strtolower(trim((string) $value))) {
'1', 'on', 'true' => self::On,
'invite', 'invite-only' => self::InviteOnly,
default => self::Off,
};
}
}