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