maintenanceTick = \Closure::fromCallable($maintenanceTick); $this->compensationTick = \Closure::fromCallable($compensationTick); } public function tick(): bool { $this->errors = []; $channels = $this->maintenanceFirst ? [ ['maintenance_notification_failed', $this->maintenanceTick], ['notification_failed', $this->compensationTick], ] : [ ['notification_failed', $this->compensationTick], ['maintenance_notification_failed', $this->maintenanceTick], ]; $this->maintenanceFirst = !$this->maintenanceFirst; $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; } }