Total Complexity | 6 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
23 | final class IndexValue |
||
24 | { |
||
25 | /** |
||
26 | * @var mixed |
||
27 | */ |
||
28 | public $value; |
||
29 | |||
30 | /** |
||
31 | * @param mixed $value |
||
32 | * |
||
33 | * @return self |
||
34 | * |
||
35 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\InvalidValueType |
||
36 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\EmptyValuesNotAllowed |
||
37 | */ |
||
38 | 7 | public static function create($value): self |
|
39 | { |
||
40 | 7 | self::assertIsScalar($value); |
|
41 | 6 | self::assertNotEmpty($value); |
|
42 | |||
43 | 5 | return new self($value); |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param mixed $value |
||
48 | * |
||
49 | * @return void |
||
50 | * |
||
51 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\EmptyValuesNotAllowed |
||
52 | */ |
||
53 | 6 | private static function assertNotEmpty($value): void |
|
58 | } |
||
59 | 5 | } |
|
60 | |||
61 | /** |
||
62 | * @param mixed $value |
||
63 | * |
||
64 | * @return void |
||
65 | * |
||
66 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\InvalidValueType |
||
67 | */ |
||
68 | 7 | private static function assertIsScalar($value): void |
|
74 | ); |
||
75 | } |
||
76 | 6 | } |
|
77 | |||
78 | /** |
||
79 | * @param mixed $value |
||
80 | */ |
||
81 | 5 | private function __construct($value) |
|
86 |