We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 020e4f2 commit a0e98a2Copy full SHA for a0e98a2
1 file changed
src/Response/Result/Hit.php
@@ -175,6 +175,30 @@ public function getIntegerOrNullValue(string $key): int|null
175
}
176
177
178
+ public function getFloatValue(string $key): float
179
+ {
180
+ if (
181
+ isset($this->source[$key])
182
+ && \is_float($this->source[$key]) === TRUE
183
+ ) {
184
+ return $this->source[$key];
185
+ }
186
+
187
+ throw new \Spameri\ElasticQuery\Exception\InvalidArgumentException(\sprintf('Value for key %s is not float.', $key));
188
189
190
191
+ public function getFloatOrNullValue(string $key): float|null
192
193
+ try {
194
+ return $this->getFloatValue($key);
195
196
+ } catch (\Spameri\ElasticQuery\Exception\InvalidArgumentException $exception) {
197
+ return NULL;
198
199
200
201
202
/**
203
* @phpstan-return mixed
204
*/
0 commit comments