/** * Sets the distance matrix request travel mode. * * @param string $travelMode The distance matrix request travel mode. * * @throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the travel mode is not valid. */ public function setTravelMode($travelMode = null) { $travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT)); if (!in_array($travelMode, $travelModes) && $travelMode !== null) { throw DistanceMatrixException::invalidDistanceMatrixRequestTravelMode(); } $this->travelMode = $travelMode; }
/** * Gets the "INVALID DIRECTIONS STEP TRAVEL MODE" exception. * * @return \Ivory\GoogleMap\Exception\DirectionsException The "INVALID DIRECTIONS STEP TRAVEL MODE" exception. */ public static function invalidDirectionsStepTravelMode() { return new static(sprintf('The directions step travel mode can only be : %s.', implode(', ', TravelMode::getTravelModes()))); }
/** * Sets the directions request travel mode. * * @param string $travelMode The directions request travel mode. * * @throws \Ivory\GoogleMap\Exception\DirectionsException If the travel mode is not valid. */ public function setTravelMode($travelMode = null) { if (!in_array($travelMode, TravelMode::getTravelModes()) && $travelMode !== null) { throw DirectionsException::invalidDirectionsRequestTravelMode(); } $this->travelMode = $travelMode; }
public function testTravelModes() { $expected = array(TravelMode::BICYCLING, TravelMode::DRIVING, TravelMode::WALKING, TravelMode::TRANSIT); $this->assertSame($expected, TravelMode::getTravelModes()); }
/** * Sets the step travel mode. * * @param string $travelMode The step travel mode. * * @throws \Ivory\GoogleMap\Exception\DirectionsException If the travel mode is not valid. */ public function setTravelMode($travelMode) { if (!in_array($travelMode, TravelMode::getTravelModes())) { throw DirectionsException::invalidDirectionsStepTravelMode(); } $this->travelMode = $travelMode; }
/** * Gets the "INVALID DISTANCE MATRIX REQUEST TRAVEL MODE" exception. * * @return \Ivory\GoogleMap\Exception\DistanceMatrixException The "INVALID DISTANCE MATRIX REQUEST TRAVEL MODE" exception. */ public static function invalidDistanceMatrixRequestTravelMode() { $travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT)); return new static(sprintf('The distance matrix request travel mode can only be : %s.', implode(', ', $travelModes))); }