Combines multiple directional properties of margin/padding into single definition.
Parameters
(string) val: Rule Set:
File
-
advagg_css_compress/
css-compressor-3.x/ src/ lib/ Combine/ MarginPadding.inc, line 41
Class
- CSSCompression_Combine_MarginPadding
- CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com
Code
public function combine($val) {
$val = $this->expand($val);
$storage = $this->storage($val);
$pos = 0;
// Now rebuild the string replacing all instances of margin/padding if shorthand exists
while (preg_match($this->rmp, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$prop = $match[2][0];
if (isset($storage[$prop])) {
$colon = strlen($match[1][0]);
$val = substr_replace($val, $storage[$prop], $match[0][1] + $colon, strlen($match[0][0]) - $colon);
$pos = $match[0][1] + strlen($storage[$prop]) - $colon - 1;
$storage[$prop] = '';
}
else {
$pos = $match[0][1] + strlen($match[0][0]) - 1;
}
}
// Return converted val
return $val;
}