Border.inc in Advanced CSS/JS Aggregation 6
File
advagg_css_compress/css-compressor-3.x/src/lib/Combine/Border.inc
View source
<?php
class CSSCompression_Combine_Border {
private $Control;
private $Combine;
private $rborder = "/(^|(?<!\\\\);)border-(top|right|bottom|left):(.*?)((?<!\\\\);|\$)/";
public function __construct(CSSCompression_Control $control, CSSCompression_Combine $combine) {
$this->Control = $control;
$this->Combine = $combine;
}
public function combine($val) {
if (($replace = $this
->replace($val)) === false) {
return $val;
}
$pos = 0;
while (preg_match($this->rborder, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$colon = strlen($match[1][0]);
$val = substr_replace($val, $replace, $match[0][1] + $colon, strlen($match[0][0]) - $colon);
$pos = $match[0][1] + strlen($replace) - $colon - 1;
$replace = '';
}
return $val;
}
private function replace($val) {
$storage = array();
$pos = 0;
while (preg_match($this->rborder, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$storage[$match[2][0]] = $match[3][0];
$pos = $match[0][1] + strlen($match[0][0]) - 1;
}
if (count($storage) == 4 && $storage['top'] == $storage['bottom'] && $storage['left'] == $storage['right'] && $storage['top'] == $storage['right']) {
return "border:" . $storage['top'] . ';';
}
return false;
}
public function access($method, $args) {
if (method_exists($this, $method)) {
return call_user_func_array(array(
$this,
$method,
), $args);
}
else {
throw new CSSCompression_Exception("Unknown method in Border Class - " . $method);
}
}
}