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.

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

Хуков нет.

Возвращает

Массив<Строку,. string> The expanded border values.

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

// private - только в коде основоного (родительского) класса
$result = $this->expand_shorthand_value( $value ): array;
$value(строка) (обязательный)
The shorthand border value.

Код Border_Style_Postprocessor::expand_shorthand_value() WC 10.8.1

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

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

	return array();
}