File tree 2 files changed +40
-0
lines changed
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)
87
87
* @returns FileInfo[]
88
88
*/
89
89
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 ()
90
110
{
91
111
if ($ this ->closed || !$ this ->file ) {
92
112
throw new ArchiveIOException ('Can not read from a closed archive ' );
@@ -103,6 +123,7 @@ public function contents()
103
123
}
104
124
105
125
$ this ->close ();
126
+
106
127
}
107
128
108
129
/**
Original file line number Diff line number Diff line change @@ -72,6 +72,25 @@ public function open($file)
72
72
* @return FileInfo[]
73
73
*/
74
74
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 ()
75
94
{
76
95
if ($ this ->closed || !$ this ->file ) {
77
96
throw new ArchiveIOException ('Can not read from a closed archive ' );
You can’t perform that action at this time.
0 commit comments