maintenanceTick = \Closure::fromCallable($maintenanceTick); $this->compensationTick = \Closure::fromCallable($compensationTick); $this->abuseAlertTick = \Closure::fromCallable($abuseAlertTick); } public function tick(): bool { $this->errors = []; $catalog = [ ['maintenance_notification_failed', $this->maintenanceTick], ['notification_failed', $this->compensationTick], ['abuse_alert_notification_failed', $this->abuseAlertTick], ]; $channels = []; for ($offset = 0; $offset < count($catalog); $offset++) { $channels[] = $catalog[ ($this->firstChannel + $offset) % count($catalog) ]; } $this->firstChannel = ($this->firstChannel + 1) % count($catalog); $worked = false; foreach ($channels as [$errorCode, $tick]) { try { $worked = $tick() === true || $worked; } catch (\Throwable $error) { $this->errors[] = $errorCode; fwrite( STDERR, 'cloud notification channel temporarily unavailable: ' . $errorCode . PHP_EOL ); } } return $worked; } /** @return list */ public function observationErrors(): array { return $this->errors; } }