You are here

public static function Openlayers::floatval_if_numeric in Openlayers 7.3

Ensures a value is of type float or integer if it is a numeric value.

Parameters

mixed $var: The value to type cast if possible.

Return value

float|mixed The variable - casted to type float if possible.

File

src/Openlayers.php, line 326
Contains Openlayers.

Class

Openlayers
Class Openlayers.

Namespace

Drupal\openlayers

Code

public static function floatval_if_numeric($var) {
  if (is_numeric($var)) {
    return is_float($var + 0) ? floatval($var) : intval($var);
  }
  return $var;
}