Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ direction LR
namespace AiClientNamespace.Providers {
class ProviderRegistry {
+registerProvider(string $className) void
+getRegisteredProviderIds() string[]
+hasProvider(string $idOrClassName) bool
+getProviderClassName(string $id) string
+isProviderConfigured(string $idOrClassName) bool
Expand Down
12 changes: 12 additions & 0 deletions src/Providers/ProviderRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@
$this->registeredClassNames[$className] = true;
}

/**
* Gets a list of all registered provider IDs.
*
* @since 0.1.0
*
* @return list<class-string<ProviderInterface> List of registered provider IDs.

Check failure on line 121 in src/Providers/ProviderRegistry.php

View workflow job for this annotation

GitHub Actions / PHP

PHPDoc tag @return has invalid value (list<class-string<ProviderInterface> List of registered provider IDs.): Unexpected token "List", expected '>' at offset 141 on line 6
*/
public function getRegisteredProviderIds(): array

Check failure on line 123 in src/Providers/ProviderRegistry.php

View workflow job for this annotation

GitHub Actions / PHP

Method WordPress\AiClient\Providers\ProviderRegistry::getRegisteredProviderIds() return type has no value type specified in iterable type array.
{
return array_keys($this->providerClassNames);
}

/**
* Checks if a provider is registered.
*
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/Providers/ProviderRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public function testRegisterProviderWithNonExistentClass(): void
$this->registry->registerProvider('NonExistentProvider');
}

/**
* Tests that getRegisteredProviderIds returns the correct provider IDs.
*
* @return void
*/
public function testGetRegisteredProviderIds(): void
{
$this->registry->registerProvider(MockProvider::class);

$this->assertEquals(['mock'], $this->registry->getRegisteredProviderIds());

// To test with multiple providers, we would need another mock provider class.
// For now, this covers the basic functionality.
}

/**
* Tests hasProvider with unregistered provider.
*
Expand Down
Loading