proxy = $proxy; $this->handlers = array( self::MCP_EVENT_UPDATED => WebsiteUpdated::class, self::MCP_EVENT_PAGE_UPDATED => WebsitePageUpdated::class, self::MCP_EVENT_OPTIN_TOGGLED => WebsiteMcpOptInToggled::class, ); } public function get_handler( string $event ) { $handler = $this->handlers[ $event ] ?? false; if ( ! $handler ) { throw new \WP_Exception( 'Invalid event' ); } return new $handler( $this->proxy ); } }