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