Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor

CssToAttributeConverter::parseCssShorthandValueprivateWC 1.0

Parses a shorthand CSS value and splits it into individual values. For example: padding: 0 auto; - 0 auto is split into top: 0, left: auto, bottom: 0, right: auto.

Method of the class: CssToAttributeConverter{}

No Hooks.

Returns

Array. string> an array of values for top, right, bottom and left (using these as associative array keys)

Usage

// private - for code of main (parent) class only
$result = $this->parseCssShorthandValue( $value ): array;
$value(string) (required)
a CSS property value with 1, 2, 3 or 4 sizes.

CssToAttributeConverter::parseCssShorthandValue() code WC 10.8.1

private function parseCssShorthandValue(string $value): array
{
    $values = (new Preg())->split('/\\s+/', $value);

    $css = [];
    $css['top'] = $values[0];
    $css['right'] = (\count($values) > 1) ? $values[1] : $css['top'];
    $css['bottom'] = (\count($values) > 2) ? $values[2] : $css['top'];
    $css['left'] = (\count($values) > 3) ? $values[3] : $css['right'];

    return $css;
}