| @@ 104-124 (lines=21) @@ | ||
| 101 | * |
|
| 102 | * @throws \LogicException |
|
| 103 | */ |
|
| 104 | public function addRange($from = null, $to = null, $key = null) |
|
| 105 | { |
|
| 106 | $range = array_filter( |
|
| 107 | [ |
|
| 108 | 'from' => $from, |
|
| 109 | 'to' => $to, |
|
| 110 | 'key' => $key, |
|
| 111 | ], |
|
| 112 | function ($v) { |
|
| 113 | return !is_null($v); |
|
| 114 | } |
|
| 115 | ); |
|
| 116 | ||
| 117 | if (empty($range)) { |
|
| 118 | throw new \LogicException('Either from or to must be set. Both cannot be null.'); |
|
| 119 | } |
|
| 120 | ||
| 121 | $this->ranges[] = $range; |
|
| 122 | ||
| 123 | return $this; |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * {@inheritdoc} |
|
| @@ 141-160 (lines=20) @@ | ||
| 138 | * |
|
| 139 | * @return GeoDistanceAggregation |
|
| 140 | */ |
|
| 141 | public function addRange($from = null, $to = null) |
|
| 142 | { |
|
| 143 | $range = array_filter( |
|
| 144 | [ |
|
| 145 | 'from' => $from, |
|
| 146 | 'to' => $to, |
|
| 147 | ], |
|
| 148 | function ($v) { |
|
| 149 | return !is_null($v); |
|
| 150 | } |
|
| 151 | ); |
|
| 152 | ||
| 153 | if (empty($range)) { |
|
| 154 | throw new \LogicException('Either from or to must be set. Both cannot be null.'); |
|
| 155 | } |
|
| 156 | ||
| 157 | $this->ranges[] = $range; |
|
| 158 | ||
| 159 | return $this; |
|
| 160 | } |
|
| 161 | ||
| 162 | /** |
|
| 163 | * {@inheritdoc} |
|