Skip to content

Commit 5bcdc83

Browse files
committed
refactor(document): improve id validation logic
- Updated id check to ensure it is a non-empty string - Simplified conditional structure for clarity
1 parent eafe4d0 commit 5bcdc83

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Document.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public function toArray(): array
3030
$array['body'] = $this->body->toArray();
3131
}
3232

33-
if ($this->id instanceof \Spameri\Elastic\Entity\Property\ElasticId) {
33+
if (
34+
\is_string($this->id)
35+
&& $this->id !== ''
36+
) {
3437
$array['id'] = $this->id;
3538
}
3639

0 commit comments

Comments
 (0)