Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors

Border_Style_Postprocessor::extract_width_from_shorthand_valueprivateWC 1.0

Extracts the width from a shorthand value.

Method of the class: Border_Style_Postprocessor{}

No Hooks.

Returns

String|null. The extracted width or null if no width is found.

Usage

// private - for code of main (parent) class only
$result = $this->extract_width_from_shorthand_value( $value ): ?string;
$value(string) (required)
The shorthand value.

Border_Style_Postprocessor::extract_width_from_shorthand_value() code WC 9.9.5

private function extract_width_from_shorthand_value( string $value ): ?string {
	$parts = preg_split( '/\s+/', trim( $value ) );

	foreach ( $parts as $part ) {
		if ( preg_match( '/^\d+([a-z%]+)?$/', $part ) ) {
			return $part;
		}
	}

	return null;
}