apiKey = $apiKey; $configuration = new Configuration($this->apiKey); $this->client = new Client($configuration); $this->serializer = $serializer; $this->alertContacts = []; } /** * Check if apikey is setted and suppose that api is valid * * @return bool */ public function isActive() { return !empty($this->apiKey); } public function getIo(): SymfonyStyle { return $this->io; } /** * @param SymfonyStyle $io * @return UptimeRobotApiService */ public function setIo(SymfonyStyle $io): UptimeRobotApiService { $this->io = $io; return $this; } /** * @return mixed */ public function getInterval() { return $this->interval; } /** * @param mixed $interval */ public function setInterval($interval): void { $this->interval = $interval; } /** * @param mixed $alertContactsString */ public function setAlertContactsString(?string $alertContactsString): void { $this->alertContactsString = $alertContactsString; if (!empty($alertContactsString) && $this->isActive()) { $alertContacts = explode(',', $alertContactsString); foreach ($alertContacts as $alertContactName) { $alertContact = $this->alertContactService->findbyName($alertContactName); if ($alertContact instanceof AlertContact) { $this->alertContacts[] = $alertContact; } } } } /** * @return mixed */ public function getAlertContacts() { return $this->alertContacts; } /** * @param mixed $alertContacts */ public function setAlertContacts($alertContacts): void { $this->alertContacts = $alertContacts; } /** * @return UptimeRobotMonitorService */ public function getMonitorService(): UptimeRobotMonitorService { if (null === $this->monitorService) { $this->monitorService = new UptimeRobotMonitorService($this->client); if ($this->io instanceof SymfonyStyle) { $this->monitorService->setIo($this->io); } } return $this->monitorService; } /** * @return UptimeRobotAlertContacsService */ public function getAlertContactService(): UptimeRobotAlertContacsService { if (null === $this->alertContactService) { $this->alertContactService = new UptimeRobotAlertContacsService($this->client); if ($this->io instanceof SymfonyStyle) { $this->alertContactService->setIo($this->io); } } return $this->alertContactService; } }