ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
Username.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23final readonly class Username implements UsernameInterface
24{
25 public function __construct(private string $username)
26 {
27 if (trim($username) === '') {
28 throw new \InvalidArgumentException('Username cannot be empty');
29 }
30 }
31
32 public function asString(): string
33 {
34 return $this->__toString();
35 }
36
37 public function isEmpty(): bool
38 {
39 return false;
40 }
41
42 public function __toString(): string
43 {
44 return $this->username;
45 }
46}
isEmpty()
True if this represents an empty (non-real) username.
Definition: Username.php:37
asString()
Returns the username as string.
Definition: Username.php:32
__construct(private string $username)
Definition: Username.php:25
Implementations may represent a resolved, concrete username or a null/empty value.