3 namespace Cli\Services;
9 protected ZipArchive $zip;
10 public function __construct(
11 protected string $filePath
13 $this->zip = new ZipArchive();
14 $status = $this->zip->open($this->filePath);
16 if (!file_exists($this->filePath) || $status !== true) {
17 throw new \Exception("Could not open file [{$this->filePath}] as ZIP");
21 public function getContentsOverview(): array
25 'desc' => '.env Config File',
26 'exists' => boolval($this->zip->statName('.env')),
29 'desc' => 'Themes Folder',
30 'exists' => boolval($this->zip->statName('themes')),
33 'desc' => 'Public File Uploads',
34 'exists' => boolval($this->zip->statName('public/uploads')),
36 'storage-uploads' => [
37 'desc' => 'Private File Uploads',
38 'exists' => boolval($this->zip->statName('storage/uploads')),
41 'desc' => 'Database Dump',
42 'exists' => boolval($this->zip->statName('db.sql')),
47 public function extractInto(string $directoryPath): void
49 $result = $this->zip->extractTo($directoryPath);
51 throw new \Exception("Failed extraction of ZIP into [{$directoryPath}].");