11<?php namespace io \archive \zip ;
22
3- use io \streams \{InputStream , OutputStream };
3+ use io \Channel ;
4+ use io \streams \{InputStream , FileInputStream , OutputStream , FileOutputStream };
45
56/**
67 * Zip archives hanadling
@@ -47,20 +48,32 @@ abstract class ZipFile {
4748 /**
4849 * Creation constructor
4950 *
50- * @param io.streams.OutputStream stream
51+ * @param string| io.Channel|io. streams.OutputStream $arg
5152 * @return io.archive.zip.ZipArchiveWriter
5253 */
53- public static function create (OutputStream $ stream ) {
54- return new ZipArchiveWriter ($ stream );
54+ public static function create ($ arg ) {
55+ if ($ arg instanceof Channel) {
56+ return new ZipArchiveWriter ($ arg ->out ());
57+ } else if ($ arg instanceof OutputStream) {
58+ return new ZipArchiveWriter ($ arg );
59+ } else {
60+ return new ZipArchiveWriter (new FileOutputStream ($ arg ));
61+ }
5562 }
5663
5764 /**
5865 * Read constructor
5966 *
60- * @param io.streams.InputStream stream
67+ * @param string| io.Channel|io. streams.InputStream $arg
6168 * @return io.archive.zip.ZipArchiveReader
6269 */
63- public static function open (InputStream $ stream ) {
64- return new ZipArchiveReader ($ stream );
70+ public static function open ($ arg ) {
71+ if ($ arg instanceof Channel) {
72+ return new ZipArchiveReader ($ arg ->in ());
73+ } else if ($ arg instanceof InputStream) {
74+ return new ZipArchiveReader ($ arg );
75+ } else {
76+ return new ZipArchiveReader (new FileInputStream ($ arg ));
77+ }
6578 }
6679}
0 commit comments