Skip to content

Commit

Permalink
optional index casting
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Nov 14, 2024
1 parent c3e28ba commit 8f794ed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Space.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -117,6 +117,10 @@ public function castIndex(array $fields): ?array
}
}

if ($optionalIndex) {
return null;
}

throw new Exception("Index casting failure");
}

Expand Down

0 comments on commit 8f794ed

Please sign in to comment.