Example #1
0
 /**
  * minify css
  * @param string $var
  * @return string
  */
 private function clean($var)
 {
     $compilationRules = $this->config->getCompilationRules();
     if (!empty($compilationRules)) {
         $css = preg_replace(array_keys($this->config->getCompilationRules()), array_values($this->config->getCompilationRules()), $var);
     } else {
         $css = $var;
     }
     // Remove comments
     $css = preg_replace('#/\\*.*?\\*/#s', '', $css);
     // Remove whitespace
     $css = preg_replace('/\\s*([{}|:;,])\\s+/', '$1', $css);
     // Remove trailing whitespace at the start
     $css = preg_replace('/\\s\\s+(.*)/', '$1', $css);
     // Remove unnecesairy ;'s
     $css = str_replace(';}', '}', $css);
     return trim($css);
 }