public function testIsValidWithValidTransitDepartureTimeAndArrivalTime()
 {
     $this->directionsRequest->setDestination('foo');
     $this->directionsRequest->setOrigin('bar');
     $this->directionsRequest->setTravelMode(TravelMode::TRANSIT);
     $this->directionsRequest->setArrivalTime(new DateTime());
     $this->directionsRequest->setDepartureTime(new DateTime());
     $this->assertTrue($this->directionsRequest->isValid());
 }
 /**
  * Routes the given request.
  *
  * Available prototypes:
  * - function route(string $origin, string $destination)
  * - function route(Ivory\GoogleMap\Services\Directions\DirectionsRequest $request)
  *
  * @throws \Ivory\GoogleMap\Exception\DirectionsException If the request is not valid (prototypes).
  */
 public function route()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof DirectionsRequest) {
         $directionsRequest = $args[0];
     } elseif (isset($args[0]) && is_string($args[0]) && (isset($args[1]) && is_string($args[1]))) {
         $directionsRequest = new DirectionsRequest();
         $directionsRequest->setOrigin($args[0]);
         $directionsRequest->setDestination($args[1]);
     } else {
         throw DirectionsException::invalidDirectionsRequestParameters();
     }
     if (!$directionsRequest->isValid()) {
         throw DirectionsException::invalidDirectionsRequest();
     }
     $response = $this->send($this->generateUrl($directionsRequest));
     $directionsResponse = $this->buildDirectionsResponse($this->parse($response->getBody()));
     return $directionsResponse;
 }