summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php41
1 files changed, 27 insertions, 14 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
index ab70c5e4..becafb28 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
@@ -1,45 +1,58 @@
<?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.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/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
+ * Add a range to this aggregation.
+ *
+ * @param int|float $fromValue low end of this range, exclusive (greater than or equal to)
+ * @param int|float $toValue high end of this range, exclusive (less than)
+ * @param string $key customized key value
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
- public function addRange($fromValue = null, $toValue = null)
+ public function addRange($fromValue = null, $toValue = null, $key = null)
{
if (is_null($fromValue) && is_null($toValue)) {
- throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ 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;
}
+
+ if (!is_null($key)) {
+ $range['key'] = $key;
+ }
+
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
+ * 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
+ *
+ * @return $this
*/
public function setKeyedResponse($keyed = true)
{
- return $this->setParam('keyed', (bool)$keyed);
+ return $this->setParam('keyed', (bool) $keyed);
}
-} \ No newline at end of file
+}