/** * @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; }