-
Notifications
You must be signed in to change notification settings - Fork 2
/
MultiType.php
56 lines (45 loc) · 1.08 KB
/
MultiType.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
<?php
declare(strict_types = 1);
namespace Example\Innmind\Doctrine;
use Innmind\Specification\{
Comparator,
Sign,
Composable,
};
final class MultiType implements Comparator
{
use Composable;
private string $property;
private Sign $sign;
private mixed $value;
private function __construct(string $property, Sign $sign, mixed $value)
{
$this->property = $property;
$this->sign = $sign;
$this->value = $value;
}
public static function of(mixed $value): self
{
return new self('multiType', Sign::equality, $value);
}
public static function contains(mixed $value): self
{
return new self('multiType', Sign::contains, $value);
}
public static function child(mixed $value): self
{
return new self('children.multiType', Sign::equality, $value);
}
public function property(): string
{
return $this->property;
}
public function sign(): Sign
{
return $this->sign;
}
public function value(): mixed
{
return $this->value;
}
}