diff --git a/src/Models/MultiVectorStruct.php b/src/Models/MultiVectorStruct.php index fb10df0..3a224bd 100644 --- a/src/Models/MultiVectorStruct.php +++ b/src/Models/MultiVectorStruct.php @@ -20,7 +20,7 @@ public function addVector(string $name, array $vector): void $this->vectors[$name] = $vector; } - public function getName(): string + public function getName(): ?string { if(empty($this->vectors)) { throw new InvalidArgumentException("No vectors added yet"); diff --git a/src/Models/VectorStruct.php b/src/Models/VectorStruct.php index 16c1277..127b3c2 100644 --- a/src/Models/VectorStruct.php +++ b/src/Models/VectorStruct.php @@ -26,7 +26,7 @@ public function isNamed(): bool return $this->name !== null; } - public function getName(): string + public function getName(): ?string { return $this->name; } diff --git a/src/Models/VectorStructInterface.php b/src/Models/VectorStructInterface.php index 1883c17..6c0dae4 100644 --- a/src/Models/VectorStructInterface.php +++ b/src/Models/VectorStructInterface.php @@ -9,7 +9,7 @@ interface VectorStructInterface * * @return string */ - public function getName(): string; + public function getName(): ?string; /** * Convert this vector to a search array. diff --git a/tests/Unit/Models/VectorStructTest.php b/tests/Unit/Models/VectorStructTest.php index af1897b..837ffb2 100644 --- a/tests/Unit/Models/VectorStructTest.php +++ b/tests/Unit/Models/VectorStructTest.php @@ -46,4 +46,11 @@ public function testNamedVectorStruct(): void $vector->toSearchArray() ); } + + public function testGetNameWithNullValue(): void + { + $vector = new VectorStruct([1, 2, 3]); + + $this->assertNull($vector->getName()); + } } \ No newline at end of file