public static function compress($data, $block = 9)
{
// Compress the file
if (file_exists($data)) {
$fullpath = realpath($data);
$data = file_get_contents($data);
// Create the new Bzip2 file resource, write data and close it
$bzResource = bzopen($fullpath . '.bz2', 'w');
bzwrite($bzResource, $data, strlen($data));
bzclose($bzResource);
return $fullpath . '.bz2';
// Else, compress the string
} else {
return bzcompress($data, $block);
}
}