See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 declare(strict_types=1); 3 4 namespace ZipStream\Option; 5 6 use Psr\Http\Message\StreamInterface; 7 8 final class Archive 9 { 10 const DEFAULT_DEFLATE_LEVEL = 6; 11 /** 12 * @var string 13 */ 14 private $comment = ''; 15 /** 16 * Size, in bytes, of the largest file to try 17 * and load into memory (used by 18 * addFileFromPath()). Large files may also 19 * be compressed differently; see the 20 * 'largeFileMethod' option. Default is ~20 Mb. 21 * 22 * @var int 23 */ 24 private $largeFileSize = 20 * 1024 * 1024; 25 /** 26 * How to handle large files. Legal values are 27 * Method::STORE() (the default), or 28 * Method::DEFLATE(). STORE sends the file 29 * raw and is significantly 30 * faster, while DEFLATE compresses the file 31 * and is much, much slower. Note that DEFLATE 32 * must compress the file twice and is extremely slow. 33 * 34 * @var Method 35 */ 36 private $largeFileMethod; 37 /** 38 * Boolean indicating whether or not to send 39 * the HTTP headers for this file. 40 * 41 * @var bool 42 */ 43 private $sendHttpHeaders = false; 44 /** 45 * The method called to send headers 46 * 47 * @var Callable 48 */ 49 private $httpHeaderCallback = 'header'; 50 /** 51 * Enable Zip64 extension, supporting very large 52 * archives (any size > 4 GB or file count > 64k) 53 * 54 * @var bool 55 */ 56 private $enableZip64 = true; 57 /** 58 * Enable streaming files with single read where 59 * general purpose bit 3 indicates local file header 60 * contain zero values in crc and size fields, 61 * these appear only after file contents 62 * in data descriptor block. 63 * 64 * @var bool 65 */ 66 private $zeroHeader = false; 67 /** 68 * Enable reading file stat for determining file size. 69 * When a 32-bit system reads file size that is 70 * over 2 GB, invalid value appears in file size 71 * due to integer overflow. Should be disabled on 72 * 32-bit systems with method addFileFromPath 73 * if any file may exceed 2 GB. In this case file 74 * will be read in blocks and correct size will be 75 * determined from content. 76 * 77 * @var bool 78 */ 79 private $statFiles = true; 80 /** 81 * Enable flush after every write to output stream. 82 * @var bool 83 */ 84 private $flushOutput = false; 85 /** 86 * HTTP Content-Disposition. Defaults to 87 * 'attachment', where 88 * FILENAME is the specified filename. 89 * 90 * Note that this does nothing if you are 91 * not sending HTTP headers. 92 * 93 * @var string 94 */ 95 private $contentDisposition = 'attachment'; 96 /** 97 * Note that this does nothing if you are 98 * not sending HTTP headers. 99 * 100 * @var string 101 */ 102 private $contentType = 'application/x-zip'; 103 /** 104 * @var int 105 */ 106 private $deflateLevel = 6; 107 108 /** 109 * @var StreamInterface|resource 110 */ 111 private $outputStream; 112 113 /** 114 * Options constructor. 115 */ 116 public function __construct() 117 { 118 $this->largeFileMethod = Method::STORE(); 119 $this->outputStream = fopen('php://output', 'wb'); 120 } 121 122 public function getComment(): string 123 { 124 return $this->comment; 125 } 126 127 public function setComment(string $comment): void 128 { 129 $this->comment = $comment; 130 } 131 132 public function getLargeFileSize(): int 133 { 134 return $this->largeFileSize; 135 } 136 137 public function setLargeFileSize(int $largeFileSize): void 138 { 139 $this->largeFileSize = $largeFileSize; 140 } 141 142 public function getLargeFileMethod(): Method 143 { 144 return $this->largeFileMethod; 145 } 146 147 public function setLargeFileMethod(Method $largeFileMethod): void 148 { 149 $this->largeFileMethod = $largeFileMethod; 150 } 151 152 public function isSendHttpHeaders(): bool 153 { 154 return $this->sendHttpHeaders; 155 } 156 157 public function setSendHttpHeaders(bool $sendHttpHeaders): void 158 { 159 $this->sendHttpHeaders = $sendHttpHeaders; 160 } 161 162 public function getHttpHeaderCallback(): Callable 163 { 164 return $this->httpHeaderCallback; 165 } 166 167 public function setHttpHeaderCallback(Callable $httpHeaderCallback): void 168 { 169 $this->httpHeaderCallback = $httpHeaderCallback; 170 } 171 172 public function isEnableZip64(): bool 173 { 174 return $this->enableZip64; 175 } 176 177 public function setEnableZip64(bool $enableZip64): void 178 { 179 $this->enableZip64 = $enableZip64; 180 } 181 182 public function isZeroHeader(): bool 183 { 184 return $this->zeroHeader; 185 } 186 187 public function setZeroHeader(bool $zeroHeader): void 188 { 189 $this->zeroHeader = $zeroHeader; 190 } 191 192 public function isFlushOutput(): bool 193 { 194 return $this->flushOutput; 195 } 196 197 public function setFlushOutput(bool $flushOutput): void 198 { 199 $this->flushOutput = $flushOutput; 200 } 201 202 public function isStatFiles(): bool 203 { 204 return $this->statFiles; 205 } 206 207 public function setStatFiles(bool $statFiles): void 208 { 209 $this->statFiles = $statFiles; 210 } 211 212 public function getContentDisposition(): string 213 { 214 return $this->contentDisposition; 215 } 216 217 public function setContentDisposition(string $contentDisposition): void 218 { 219 $this->contentDisposition = $contentDisposition; 220 } 221 222 public function getContentType(): string 223 { 224 return $this->contentType; 225 } 226 227 public function setContentType(string $contentType): void 228 { 229 $this->contentType = $contentType; 230 } 231 232 /** 233 * @return StreamInterface|resource 234 */ 235 public function getOutputStream() 236 { 237 return $this->outputStream; 238 } 239 240 /** 241 * @param StreamInterface|resource $outputStream 242 */ 243 public function setOutputStream($outputStream): void 244 { 245 $this->outputStream = $outputStream; 246 } 247 248 /** 249 * @return int 250 */ 251 public function getDeflateLevel(): int 252 { 253 return $this->deflateLevel; 254 } 255 256 /** 257 * @param int $deflateLevel 258 */ 259 public function setDeflateLevel(int $deflateLevel): void 260 { 261 $this->deflateLevel = $deflateLevel; 262 } 263 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body