binAdapter = $binAdapter; $this->flatpakAdapter = $flatpakAdapter; $this->sysAdapter = $sysAdapter; $this->logger = $logger; } private function findAvailableAdapter(): ?Adapter { if ($this->binAdapter->isAvailable()) { $this->binAdapter->setLogger($this->logger); return $this->binAdapter; } if ($this->flatpakAdapter->isAvailable()) { return $this->flatpakAdapter; } if ($this->sysAdapter->isAvailable()) { $this->sysAdapter->setLogger($this->logger); return $this->sysAdapter; } return null; } public function extract(string $content): Itinerary { if ($this->adapter === null) { $this->adapter = $this->findAvailableAdapter() ?? false; } if ($this->adapter === false) { $this->logger->info('KItinerary binary adapter is not available, can\'t extract information'); return new Itinerary(); } try { return (new Extractor($this->adapter))->extractFromString($content); } catch (KItineraryRuntimeException $e) { $this->logger->error('Could not extract itinerary function from KItinerary integration: ' . $e->getMessage(), [ 'exception' => $e, ]); return new Itinerary(); } } }