lib/Minify/JS/ClosureCompiler.php
public function min($js)
    {
        $postBody = $this->buildPostBody($js);

        if ($this->maxBytes > 0) {
            $bytes = (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
                ? mb_strlen($postBody, '8bit')
                : strlen($postBody);
            if ($bytes > $this->maxBytes) {
                throw new Minify_JS_ClosureCompiler_Exception(
                    'POST content larger than ' . $this->maxBytes . ' bytes'
                );
            }
        }

        $response = $this->getResponse($postBody);

        if (preg_match('/^Error\(\d\d?\):/', $response)) {
            if (is_callable($this->fallbackMinifier)) {
                // use fallback
                $response = "/* Received errors from Closure Compiler API:\n$response"
                          . "\n(Using fallback minifier)\n*/\n";
                $response .= call_user_func($this->fallbackMinifier, $js);
            } else {
                throw new Minify_JS_ClosureCompiler_Exception($response);
            }
        }

        if ($response === '') {
            $errors = $this->getResponse($this->buildPostBody($js, true));
            throw new Minify_JS_ClosureCompiler_Exception($errors);
        }

        return $response;
    }
public function min($js)
    {
        $postBody = $this->buildPostBody($js);

        if ($this->maxBytes > 0) {
            $bytes = (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
                ? mb_strlen($postBody, '8bit')
                : strlen($postBody);
            if ($bytes > $this->maxBytes) {
                throw new Minify_JS_ClosureCompiler_Exception(
                    'POST content larger than ' . $this->maxBytes . ' bytes'
                );
            }
        }

        $response = $this->getResponse($postBody);

        if (preg_match('/^Error\(\d\d?\):/', $response)) {
            if (is_callable($this->fallbackMinifier)) {
                // use fallback
                $response = "/* Received errors from Closure Compiler API:\n$response"
                          . "\n(Using fallback minifier)\n*/\n";
                $response .= call_user_func($this->fallbackMinifier, $js);
            } else {
                throw new Minify_JS_ClosureCompiler_Exception($response);
            }
        }

        if ($response === '') {
            $errors = $this->getResponse($this->buildPostBody($js, true));
            throw new Minify_JS_ClosureCompiler_Exception($errors);
        }

        return $response;
    }
public function min ( $ js ) { $ postBody = $ this -> buildPostBody ( $ js ) ; if ( $ this -> maxBytes > 0 ) { $ bytes = ( function_exists ( 'mb_strlen' ) && ( ( int ) ini_get ( 'mbstring.func_overload' ) & 2 ) ) ? mb_strlen ( $ postBody , '8bit' ) : strlen ( $ postBody ) ; if ( $ bytes > $ this -> maxBytes ) { throw new Minify_JS_ClosureCompiler_Exception ( 'POST content larger than ' . $ this -> maxBytes . ' bytes' ) ; } } $ response = $ this -> getResponse ( $ postBody ) ; if ( preg_match ( '/^Error\(\d\d?\):/' , $ response ) ) { if ( is_callable ( $ this -> fallbackMinifier ) ) { // use fallback $ response = "/* Received errors from Closure Compiler API:\n$response" . "\n(Using fallback minifier)\n*/\n" ; $ response .= call_user_func ( $ this -> fallbackMinifier , $ js ) ; } else { throw new Minify_JS_ClosureCompiler_Exception ( $ response ) ; } } if ( $ response === '' ) { $ errors = $ this -> getResponse ( $ this -> buildPostBody ( $ js , true ) ) ; throw new Minify_JS_ClosureCompiler_Exception ( $ errors ) ; } return $ response ; }
Call the service to perform the minification

@param string $js JavaScript code
@return string
@throws Minify_JS_ClosureCompiler_Exception
Call the service to perform the minification