diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
commit | 1a365e77dfb8825136626202b1df462731b42060 (patch) | |
tree | 1dc4468eaabf070e051e790a9e67a9a9a2c63d99 /vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php | |
parent | a72fd280f7acb4d2a1ba579a0f1b2b2ae8958530 (diff) |
Update to MediaWiki 1.25.2
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php new file mode 100644 index 00000000..ab70c5e4 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php @@ -0,0 +1,45 @@ +<?php +namespace Elastica\Aggregation; + + +use Elastica\Exception\InvalidException; + +/** + * Class Range + * @package Elastica\Aggregation + * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-range-aggregation.html + */ +class Range extends AbstractSimpleAggregation +{ + /** + * Add a range to this aggregation + * @param int|float $fromValue low end of this range, exclusive (greater than) + * @param int|float $toValue high end of this range, exclusive (less than) + * @return Range + * @throws \Elastica\Exception\InvalidException + */ + public function addRange($fromValue = null, $toValue = null) + { + if (is_null($fromValue) && is_null($toValue)) { + throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null."); + } + $range = array(); + if (!is_null($fromValue)) { + $range['from'] = $fromValue; + } + if (!is_null($toValue)) { + $range['to'] = $toValue; + } + return $this->addParam('ranges', $range); + } + + /** + * If set to true, a unique string key will be associated with each bucket, and ranges will be returned as an associative array + * @param bool $keyed + * @return Range + */ + public function setKeyedResponse($keyed = true) + { + return $this->setParam('keyed', (bool)$keyed); + } +}
\ No newline at end of file |