Minify_JS_ClosureCompiler::min PHP Method

min() public method

Call the service to perform the minification
public min ( string $js ) : string
$js string JavaScript code
return string
    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;
    }