Total Complexity | 5 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 84.62% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
23 | final class IndexKey |
||
24 | { |
||
25 | public string $indexName; |
||
26 | |||
27 | public string $valueKey; |
||
28 | |||
29 | /** |
||
30 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\IndexNameCantBeEmpty |
||
31 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\ValueKeyCantBeEmpty |
||
32 | */ |
||
33 | 4 | public function __construct(string $indexName, string $valueKey) |
|
34 | { |
||
35 | 4 | self::assertIndexNameIsNotEmpty($indexName); |
|
36 | 4 | self::assertValueKeyIsNotEmpty($valueKey); |
|
37 | |||
38 | 4 | $this->indexName = $indexName; |
|
39 | 4 | $this->valueKey = $valueKey; |
|
40 | 4 | } |
|
41 | |||
42 | /** |
||
43 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\IndexNameCantBeEmpty |
||
44 | */ |
||
45 | 4 | private static function assertIndexNameIsNotEmpty(string $indexName): void |
|
46 | { |
||
47 | 4 | if ('' === $indexName) |
|
48 | { |
||
49 | throw new IndexNameCantBeEmpty('Index name can\'t be empty'); |
||
50 | } |
||
51 | 4 | } |
|
52 | |||
53 | /** |
||
54 | * @throws \ServiceBus\EventSourcing\Indexes\Exceptions\ValueKeyCantBeEmpty |
||
55 | */ |
||
56 | 4 | private static function assertValueKeyIsNotEmpty(string $valueKey): void |
|
61 | } |
||
62 | 4 | } |
|
63 | } |
||
64 |