Add MD_STD_IN::boolval()

This commit is contained in:
2026-04-09 18:17:58 +02:00
parent 7ff6447d8d
commit 38cb5c785d

View File

@@ -131,6 +131,20 @@ final class MD_STD_IN {
}
/**
* Converts an input value into a bool. Different from the default PHP way,
* the strings "false" and "False" are treated as negative.
*
* @param mixed $inputs Input data.
*
* @return boolean
*/
public static function boolval(mixed $inputs):bool {
if (is_string($inputs) && (strtolower($inputs) === "false")) return false;
return (bool)$inputs;
}
/**
* Validates an input array for all entries being strings. Unsets empty values.
* This is especially useful for parsed JSON.