public function __destruct()
{
// Compress the archive on exit
if ($this->compression != Compression::NONE()) {
// Due to the way Phar works, it MUST create a new archive with a different extension. We will allow this,
// then rename the new archive back to the original filename
$ext = uniqid();
$fn = substr($this->filename, 0, strrpos($this->filename, '.') ?: null);
$this->archive->compress((int) $this->compression->value(), $ext);
// New archive does not get created on empty databases
if (file_exists($fn . '.' . $ext)) {
rename($fn . '.' . $ext, $this->filename);
}
}
}