You are here

private function CSSCompression_Combine_BorderRadius::storage in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 advagg_css_compress/css-compressor-3.x/src/lib/Combine/BorderRadius.inc \CSSCompression_Combine_BorderRadius::storage()

Builds the storage object for border radius props

Parameters

(string) val: Rule Set:

(array) regex: Current border radius type checking props:

1 call to CSSCompression_Combine_BorderRadius::storage()
CSSCompression_Combine_BorderRadius::fix in advagg_css_compress/css-compressor-3.x/src/lib/Combine/BorderRadius.inc
Does the actual combining

File

advagg_css_compress/css-compressor-3.x/src/lib/Combine/BorderRadius.inc, line 214

Class

CSSCompression_Combine_BorderRadius
CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com

Code

private function storage($val, $regex) {
  $storage = array(
    'horizontal' => array(
      'replace' => '',
    ),
    'vertical' => array(
      'replace' => '',
      'keep' => false,
    ),
  );

  // Find all possible occurences of this border-radius type and mark their directional value
  $pos = 0;
  while (preg_match($regex['full'], $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
    $pos = $match[0][1] + strlen($match[0][0]) - 1;
    $parts = preg_split($this->rspace, $match[4][0], 2);
    $storage['horizontal'][$match[2][0] . '-' . $match[3][0]] = trim($parts[0]);
    if (isset($parts[1])) {
      $storage['vertical'][$match[2][0] . '-' . $match[3][0]] = trim($parts[1]);
      $storage['vertical']['keep'] = true;
      $storage['vertical']['replace'] = '/';
    }
    else {
      $storage['vertical'][$match[2][0] . '-' . $match[3][0]] = '0';
    }
  }

  // Only combine if all 4 definitions are found (5 including replace)
  if (count($storage['horizontal']) != 5 || $this->Combine
    ->checkUncombinables($storage['horizontal']) || $this->Combine
    ->checkUncombinables($storage['vertical'])) {
    return false;
  }
  return $storage;
}