Frontend\Core\Engine\Header::minifyCSS PHP Method

minifyCSS() private method

Minify a CSS-file
private minifyCSS ( string $file ) : string
$file string The file to be minified.
return string
    private function minifyCSS($file)
    {
        $fileName = md5($file) . '.css';
        $finalURL = FRONTEND_CACHE_URL . '/MinifiedCss/' . $fileName;
        $finalPath = FRONTEND_CACHE_PATH . '/MinifiedCss/' . $fileName;
        // check that file does not yet exist or has been updated already
        $filesystem = new Filesystem();
        if (!$filesystem->exists($finalPath) || filemtime(PATH_WWW . $file) > filemtime($finalPath)) {
            // create directory if it does not exist
            if (!$filesystem->exists(dirname($finalPath))) {
                $filesystem->mkdir(dirname($finalPath));
            }
            // minify the file
            $css = new Minify\CSS(PATH_WWW . $file);
            $css->minify($finalPath);
        }
        return $finalURL;
    }