1 | <?php |
||
11 | class SongZipArchive |
||
12 | { |
||
13 | /** |
||
14 | * @var ZipArchive |
||
15 | */ |
||
16 | protected $archive; |
||
17 | |||
18 | /** |
||
19 | * Path to the zip archive |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $path; |
||
24 | |||
25 | /** |
||
26 | * Names of the files in the archive |
||
27 | * Format: [file-name.mp3' => currentFileIndex] |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $fileNames = []; |
||
32 | |||
33 | /** |
||
34 | * @param string $path |
||
35 | * |
||
36 | * @throws Exception |
||
37 | */ |
||
38 | public function __construct($path = '') |
||
56 | |||
57 | /** |
||
58 | * Add multiple songs into the archive. |
||
59 | * |
||
60 | * @param Collection $songs |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function addSongs(Collection $songs) |
||
72 | |||
73 | /** |
||
74 | * Add a single song into the archive. |
||
75 | * |
||
76 | * @param Song $song |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function addSong(Song $song) |
||
106 | |||
107 | /** |
||
108 | * Finish (close) the archive. |
||
109 | * |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function finish() |
||
118 | |||
119 | /** |
||
120 | * Get the path to the archive. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getPath() |
||
128 | } |
||
129 |