Automattic\WooCommerce\EmailEditor\Integrations\Utils

Styles_Helper::parse_value │ public static │ WC 1.0

Parse number value from a string.

Метод класса: Styles_Helper{}

Хуков нет.

Возвращает

float.

Использование

$result = Styles_Helper::parse_value( $value ): float;
$value(строка|float|int) (обязательный)
String with value and unit or integer value.

Код Styles_Helper::parse_value() WC 11.3.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;
}