Skip to content

Commit

Permalink
getName method return type changed as nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
hkulekci committed Aug 9, 2023
1 parent 5b69412 commit 9ea7520
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Models/MultiVectorStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/Models/VectorStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function isNamed(): bool
return $this->name !== null;
}

public function getName(): string
public function getName(): ?string
{
return $this->name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/VectorStructInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface VectorStructInterface
*
* @return string
*/
public function getName(): string;
public function getName(): ?string;

/**
* Convert this vector to a search array.
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Models/VectorStructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,11 @@ public function testNamedVectorStruct(): void
$vector->toSearchArray()
);
}

public function testGetNameWithNullValue(): void
{
$vector = new VectorStruct([1, 2, 3]);

$this->assertNull($vector->getName());
}
}

0 comments on commit 9ea7520

Please sign in to comment.