*/ private array $collectors = array(); /** * Registered panels keyed by their panel key (matches collector key). * * @var array */ private array $panels = array(); /** * Private constructor — use instance(). */ private function __construct() {} /** * Get (or create) the singleton instance. * * @return static */ public static function instance(): static { if ( null === static::$instance ) { static::$instance = new static(); } return static::$instance; } /** * Register a data collector. * * @param PRV_Data_Collector $collector The collector to register. * * @return void */ public function register_collector( PRV_Data_Collector $collector ): void { $this->collectors[ $collector->get_key() ] = $collector; } /** * Register a dashboard panel. * * @param string $key Panel key (must match a collector key). * @param PRV_Dashboard_Panel $panel The panel to register. * * @return void */ public function register_panel( string $key, PRV_Dashboard_Panel $panel ): void { $this->panels[ $key ] = $panel; } /** * Get all registered collectors. * * @return array */ public function get_collectors(): array { return $this->collectors; } /** * Get the panel for a given key (null when not registered). * * @param string $key Panel key. * * @return PRV_Dashboard_Panel|null */ public function get_panel( string $key ): ?PRV_Dashboard_Panel { return $this->panels[ $key ] ?? null; } /** * Reset the registry — test use only. * * @internal * @return void */ public static function reset_for_testing(): void { static::$instance = null; } }