-
Notifications
You must be signed in to change notification settings - Fork 2
/
Username.php
64 lines (51 loc) · 1.23 KB
/
Username.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types = 1);
namespace Example\Innmind\Doctrine;
use Innmind\Specification\{
Comparator,
Sign,
Composable,
};
final class Username implements Comparator
{
use Composable;
private string|array $value;
private Sign $sign;
private function __construct(string|array $value, Sign $sign)
{
$this->value = $value;
$this->sign = $sign;
}
public static function of(string $username): self
{
return new self($username, Sign::equality);
}
public static function in(string ...$usernames): self
{
return new self($usernames, Sign::in);
}
public static function startsWith(string $username): self
{
return new self($username, Sign::startsWith);
}
public static function endsWith(string $username): self
{
return new self($username, Sign::endsWith);
}
public static function contains(string $username): self
{
return new self($username, Sign::contains);
}
public function property(): string
{
return 'username';
}
public function sign(): Sign
{
return $this->sign;
}
public function value(): string|array
{
return $this->value;
}
}