/** * @return stdClass */ public function jsonSerialize() { $json = new stdClass(); $json->origin = $this->journey->getOrigin(); $json->destination = $this->journey->getDestination(); $json->departureTime = $this->getTime($this->journey->getDepartureTime()); $json->arrivalTime = $this->getTime($this->journey->getArrivalTime()); $json->legs = array_map([$this, 'getLeg'], $this->journey->getLegs()); return $json; }
/** * @param OutputInterface $out * @param array $locations * @param Journey $journey */ private function displayRoute(OutputInterface $out, array $locations, Journey $journey) { $this->outputHeading($out, "Route"); $out->writeln("Duration " . $journey->getDuration()); foreach ($journey->getLegs() as $leg) { if (!$leg->isTransfer()) { foreach ($leg->getConnections() as $connection) { $origin = sprintf('%-30s', $locations[$connection->getOrigin()]); $destination = sprintf('%30s', $locations[$connection->getDestination()]); $out->writeln(gmdate('H:i', $connection->getDepartureTime()) . ' ' . $origin . ' ' . sprintf('%-6s', $connection->getService()) . ' ' . $destination . ' ' . gmdate('H:i', $connection->getArrivalTime())); } } else { $origin = sprintf('%-30s', $locations[$leg->getOrigin()]); $destination = sprintf('%30s', $locations[$leg->getDestination()]); $out->writeln(sprintf('%-6s', $leg->getMode()) . $origin . ' to' . $destination . " (" . $leg->getDuration() / 60 . "mins)"); } } }