public static function compress($data, $level = 9, $mode = FORCE_GZIP)
{
// Compress the file
if (file_exists($data)) {
$fullpath = realpath($data);
$data = file_get_contents($data);
// Create the new Gzip file resource, write data and close it
$gzResource = fopen($fullpath . '.gz', 'w');
fwrite($gzResource, gzencode($data, $level, $mode));
fclose($gzResource);
return $fullpath . '.gz';
// Else, compress the string
} else {
return gzencode($data, $level, $mode);
}
}