Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ public function registerProvider(string $className): void
$this->registeredClassNames[$className] = true;
}

/**
* Gets a list of all registered provider IDs.
*
* @since 0.1.0
*
* @return list<string> List of registered provider IDs.
*/
public function getRegisteredProviderIds(): 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