Skip to content

Commit e4829cd

Browse files
authored
Merge pull request hkulekci#30 from hkulekci/bug-fix-for-get-name
2 parents 5b69412 + 9ea7520 commit e4829cd

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/Models/MultiVectorStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function addVector(string $name, array $vector): void
2020
$this->vectors[$name] = $vector;
2121
}
2222

23-
public function getName(): string
23+
public function getName(): ?string
2424
{
2525
if(empty($this->vectors)) {
2626
throw new InvalidArgumentException("No vectors added yet");

src/Models/VectorStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function isNamed(): bool
2626
return $this->name !== null;
2727
}
2828

29-
public function getName(): string
29+
public function getName(): ?string
3030
{
3131
return $this->name;
3232
}

src/Models/VectorStructInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface VectorStructInterface
99
*
1010
* @return string
1111
*/
12-
public function getName(): string;
12+
public function getName(): ?string;
1313

1414
/**
1515
* Convert this vector to a search array.

tests/Unit/Models/VectorStructTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,11 @@ public function testNamedVectorStruct(): void
4646
$vector->toSearchArray()
4747
);
4848
}
49+
50+
public function testGetNameWithNullValue(): void
51+
{
52+
$vector = new VectorStruct([1, 2, 3]);
53+
54+
$this->assertNull($vector->getName());
55+
}
4956
}

0 commit comments

Comments
 (0)