Automattic\WooCommerce\EmailEditor\Integrations\Utils
Styles_Helper::parse_value
Parse number value from a string.
Method of the class: Styles_Helper{}
No Hooks.
Returns
float.
Usage
$result = Styles_Helper::parse_value( $value ): float;
- $value(string|float|int) (required)
- String with value and unit or integer value.
Styles_Helper::parse_value() Styles Helper::parse value code WC 10.5.0
public static function parse_value( $value ): float {
// Handle numeric values.
if ( is_numeric( $value ) ) {
return (float) $value;
}
// Handle string values.
if ( is_string( $value ) ) {
if ( preg_match( '/^\s*(-?\d+(?:\.\d+)?)/', $value, $m ) ) {
return (float) $m[1];
}
}
return 0.0;
}