File: //wordpress/plugins/wp-cloud-client/1.1.5/src/Handler/HandlerRegistry.php
<?php
declare(strict_types=1);
namespace VPlugins\WPCloudClient\Handler;
final class HandlerRegistry {
/**
* Registered handlers keyed by action name.
*
* @var array<string, HandlerInterface>
*/
private array $handlers = [];
/**
* Register a handler for its action.
*
* @param HandlerInterface $handler Handler to register.
* @return void
*/
public function register( HandlerInterface $handler ): void {
$this->handlers[ $handler->action() ] = $handler;
}
/**
* Retrieve a handler by action name.
*
* @param string $action Action name.
* @return HandlerInterface|null Handler instance or null if not found.
*/
public function get( string $action ): ?HandlerInterface {
return $this->handlers[ $action ] ?? null;
}
/**
* Return all registered action names.
*
* @return list<string> Action names.
*/
public function actions(): array {
return array_keys( $this->handlers );
}
}