1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-08 07:06:49 +02:00

move cc-checking to constructor

This commit is contained in:
Steve Clay
2011-01-09 23:19:13 +00:00
parent 8adf606cc6
commit 1fed7e4ab8

View File

@@ -70,34 +70,30 @@ class JSMin {
protected $output = '';
/**
* Minify Javascript
* Minify Javascript.
*
* @param string $js Javascript to be minified
* @return string
*/
public static function minify($js)
{
// look out for syntax like "++ +" and "- ++"
$p = '\\+';
$m = '\\-';
if (preg_match("/([$p$m])(?:\\1 [$p$m]| (?:$p$p|$m$m))/", $js)) {
// likely pre-minified and would be broken by JSMin
return $js;
}
$jsmin = new JSMin($js);
return $jsmin->min();
}
/*
* Don't create a JSMin instance, instead use the static function minify,
* which checks for mb_string function overloading and avoids errors
* trying to re-minify the output of Closure Compiler
*
* @private
/**
* @param string $input
*/
public function __construct($input)
{
$this->input = $input;
// look out for syntax like "++ +" and "- ++"
$p = '\\+';
$m = '\\-';
if (preg_match("/([$p$m])(?:\\1 [$p$m]| (?:$p$p|$m$m))/", $input)) {
// likely pre-minified and would be broken by JSMin
$this->output = $input;
}
}
/**