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

Border_Style_Postprocessor::expand_shorthand_valueprivateWC 1.0

Expands shorthand border width and style values into individual properties.

Method of the class: Border_Style_Postprocessor{}

No Hooks.

Returns

Array. string> The expanded border values.

Usage

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

Border_Style_Postprocessor::expand_shorthand_value() code WC 9.9.5

private function expand_shorthand_value( string $value ): array {
	$values = preg_split( '/\s+/', trim( $value ) );

	if ( count( $values ) === 4 ) {
		return array(
			'top'    => $values[0],
			'right'  => $values[1],
			'bottom' => $values[2],
			'left'   => $values[3],
		);
	}
	if ( count( $values ) === 3 ) {
		return array(
			'top'    => $values[0],
			'right'  => $values[1],
			'bottom' => $values[2],
			'left'   => $values[1],
		);
	}
	if ( count( $values ) === 2 ) {
		return array(
			'top'    => $values[0],
			'right'  => $values[1],
			'bottom' => $values[0],
			'left'   => $values[1],
		);
	}
	if ( count( $values ) === 1 ) {
		return array(
			'top'    => $values[0],
			'right'  => $values[0],
			'bottom' => $values[0],
			'left'   => $values[0],
		);
	}

	return array();
}