diff --git a/src/Space.php b/src/Space.php index 6f8e307..44b9e28 100644 --- a/src/Space.php +++ b/src/Space.php @@ -87,7 +87,7 @@ public function addProperty(string $name, string $type, array $config = []) } } - public function castIndex(array $fields): ?array + public function castIndex(array $fields, bool $optionalIndex = false): ?array { foreach ($this->indexes as $index) { if ($index['fields'] == $fields) { @@ -117,6 +117,10 @@ public function castIndex(array $fields): ?array } } + if ($optionalIndex) { + return null; + } + throw new Exception("Index casting failure"); }