['host' => 'endpointA'], 'endpoint2' => ['host' => 'endpointB']]); } public static function createTransport(ConfigObject $config): ApiCommandTransport { return (new class extends ApiCommandTransport { protected function sendCommand(IcingaApiCommand $command) { if ($this->getHost() === 'endpointA') { throw (new CommandTransportException(sprintf('%s fails!', $this->getHost()))) ->setCommand($command); } return $command->getData(); } })->setHost($config->host); } }