setRanges($ranges); } } /** * @param array $ranges * @return \Elastica\Filter\GeoDistanceRange */ public function setRanges(array $ranges) { $this->_ranges = array(); foreach ($ranges as $key => $value) { $this->setRange($key, $value); } return $this; } /** * @param string $key * @param mixed $value * @return \Elastica\Filter\GeoDistanceRange * @throws \Elastica\Exception\InvalidException */ public function setRange($key, $value) { switch ($key) { case self::RANGE_TO: case self::RANGE_FROM: case self::RANGE_GT: case self::RANGE_GTE: case self::RANGE_LT: case self::RANGE_LTE: break; case self::RANGE_INCLUDE_LOWER: case self::RANGE_INCLUDE_UPPER: $value = (boolean) $value; break; default: throw new InvalidException('Invalid range parameter given: ' . $key); } $this->_ranges[$key] = $value; return $this; } /** * @return array */ public function toArray() { foreach ($this->_ranges as $key => $value) { $this->setParam($key, $value); } return parent::toArray(); } }