1<?php 2 3namespace Elastica\Aggregation; 4 5/** 6 * Class BucketSelector. 7 * 8 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html 9 */ 10class BucketSelector extends AbstractSimpleAggregation implements GapPolicyInterface 11{ 12 use Traits\GapPolicyTrait; 13 14 public function __construct(string $name, ?array $bucketsPath = null, ?string $script = null) 15 { 16 parent::__construct($name); 17 18 if (null !== $bucketsPath) { 19 $this->setBucketsPath($bucketsPath); 20 } elseif (\func_num_args() >= 2) { 21 \trigger_deprecation('ruflin/elastica', '7.4.0', 'Passing null as 2nd argument to "%s()" is deprecated, pass an array instead. It will be mandatory in 8.0.', __METHOD__); 22 } else { 23 \trigger_deprecation('ruflin/elastica', '7.4.0', 'Not passing a 2nd argument to "%s()" is deprecated, pass an array instead. It will be mandatory in 8.0.', __METHOD__); 24 } 25 26 if (null !== $script) { 27 $this->setScript($script); 28 } elseif (\func_num_args() >= 3) { 29 \trigger_deprecation('ruflin/elastica', '7.4.0', 'Passing null as 3rd argument to "%s()" is deprecated, pass a string instead. It will be mandatory in 8.0.', __METHOD__); 30 } else { 31 \trigger_deprecation('ruflin/elastica', '7.4.0', 'Not passing a 3rd argument to "%s()" is deprecated, pass a string instead. It will be mandatory in 8.0.', __METHOD__); 32 } 33 } 34 35 /** 36 * Set the buckets_path for this aggregation. 37 * 38 * @return $this 39 */ 40 public function setBucketsPath(array $bucketsPath): self 41 { 42 return $this->setParam('buckets_path', $bucketsPath); 43 } 44} 45