trim($p, DIRECTORY_SEPARATOR), $paths) ); return join(DIRECTORY_SEPARATOR, [rtrim($first, DIRECTORY_SEPARATOR), ...$paths]); } } if (! function_exists('unzip')) { /** * Unzip the given filename * * This function will attempt to unzip the given zip file name into the given location, but if the location * is not provided, we'll use the file directory. * * @param string $filename The file name of the ZIP file * @param ?string $to The location where to extract the content * @return void */ function unzip(string $filename, string $to = null): void { if (! extension_loaded('zip')) { throw new \RuntimeException('Extension [ext-zip] not found'); } $zip = new \ZipArchive(); $to ??= dirname($filename); try { $zip->open($filename); $zip->extractTo($to); } finally { $zip->close(); } } }