-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce `NullVector` and `VectorInterface` * - * - * - * -
- Loading branch information
1 parent
f91edc5
commit 08150e7
Showing
7 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpLlm\LlmChain\Document; | ||
|
||
use PhpLlm\LlmChain\Exception\RuntimeException; | ||
|
||
final class NullVector implements VectorInterface | ||
{ | ||
public function getData(): array | ||
{ | ||
throw new RuntimeException('getData() method cannot be called on a NullVector.'); | ||
} | ||
|
||
public function getDimensions(): int | ||
{ | ||
throw new RuntimeException('getDimensions() method cannot be called on a NullVector.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpLlm\LlmChain\Document; | ||
|
||
interface VectorInterface | ||
{ | ||
/** | ||
* @return list<float> | ||
*/ | ||
public function getData(): array; | ||
|
||
public function getDimensions(): int; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpLlm\LlmChain\Tests\Document; | ||
|
||
use PhpLlm\LlmChain\Document\NullVector; | ||
use PhpLlm\LlmChain\Document\VectorInterface; | ||
use PhpLlm\LlmChain\Exception\RuntimeException; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(NullVector::class)] | ||
final class NullVectorTest extends TestCase | ||
{ | ||
#[Test] | ||
public function implementsInterface(): void | ||
{ | ||
self::assertInstanceOf(VectorInterface::class, new NullVector()); | ||
} | ||
|
||
#[Test] | ||
public function getDataThrowsOnAccess(): void | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
(new NullVector())->getData(); | ||
} | ||
|
||
#[Test] | ||
public function getDimensionsThrowsOnAccess(): void | ||
{ | ||
$this->expectException(RuntimeException::class); | ||
|
||
(new NullVector())->getDimensions(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters