File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,30 @@ public function getIntegerOrNullValue(string $key): int|null
175175 }
176176
177177
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+
178202 /**
179203 * @phpstan-return mixed
180204 */
You can’t perform that action at this time.
0 commit comments