Unpacker.php 756 Bytes
Newer Older
jiangkebao's avatar
jiangkebao committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<?php

namespace Meibuyu\Micro\Tools;
use Chumper\Zipper\Zipper;

/**
 * 打包器
 * Class PackFiler
 */
class Unpacker
{
    //文件列表 一位数组
    public $fileList;
    //保存路径
    public $path;
    //文件名
    public $fileName;

    public function __construct(array $fileList, $path, $fileName)
    {
        $this->fileList = $fileList;
        $this->path = $path;
        $this->fileName = $fileName;
    }

    /**
     * 打包
     * @return string
     * @throws \Exception
     */
    public function unpack()
    {
        $zipper = new Zipper();
        $filePath = $this->path.'/'.$this->fileName.'.zip';
        $zipper->make($filePath)->add($this->fileList);
        $zipper->close();
        return $filePath;
    }
}