Visual Console Refactor: add a new util function

Former-commit-id: 8b6266651ac81fcdd18a12b71f3f316eb246277a
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-04 17:02:48 +02:00
parent f0c9957838
commit ead487b24b
1 changed files with 15 additions and 0 deletions

View File

@ -182,6 +182,21 @@ abstract class Model
}
/**
* Return a valid float or a default value from a unknown value.
*
* @param mixed $val Input value.
* @param mixed $def Default value.
*
* @return mixed A valid float extracted from the input or the
* default value.
*/
protected static function parseFloatOr($val, $def)
{
return (is_numeric($val) === true) ? (float) $val : $def;
}
/**
* Get a value from a dictionary from a possible pool of keys.
*