HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
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 );
	}
}