File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,26 @@ public function open($file)
8787 * @returns FileInfo[]
8888 */
8989 public function contents ()
90+ {
91+ $ result = array ();
92+
93+ foreach ($ this ->yieldContents () as $ fileinfo ) {
94+ $ result [] = $ file ;
95+ }
96+
97+ return $ result ;
98+ }
99+
100+ /**
101+ * Read the contents of a TAR archive and return each entry using yield
102+ * for memory efficiency.
103+ *
104+ * @see contents()
105+ * @throws ArchiveIOException
106+ * @throws ArchiveCorruptedException
107+ * @returns FileInfo[]
108+ */
109+ public function yieldContents ()
90110 {
91111 if ($ this ->closed || !$ this ->file ) {
92112 throw new ArchiveIOException ('Can not read from a closed archive ' );
@@ -103,6 +123,7 @@ public function contents()
103123 }
104124
105125 $ this ->close ();
126+
106127 }
107128
108129 /**
Original file line number Diff line number Diff line change @@ -72,6 +72,25 @@ public function open($file)
7272 * @return FileInfo[]
7373 */
7474 public function contents ()
75+ {
76+ $ result = array ();
77+
78+ foreach ($ this ->yieldContents () as $ fileinfo ) {
79+ $ result [] = $ file ;
80+ }
81+
82+ return $ result ;
83+ }
84+
85+ /**
86+ * Read the contents of a ZIP archive and return each entry using yield
87+ * for memory efficiency.
88+ *
89+ * @see contents()
90+ * @throws ArchiveIOException
91+ * @return FileInfo[]
92+ */
93+ public function yieldContents ()
7594 {
7695 if ($ this ->closed || !$ this ->file ) {
7796 throw new ArchiveIOException ('Can not read from a closed archive ' );
You can’t perform that action at this time.
0 commit comments