diff --git a/src/FileStream.php b/src/FileStream.php
index f25725f..2234b35 100644
--- a/src/FileStream.php
+++ b/src/FileStream.php
@@ -45,6 +45,12 @@ class FileStream extends BaseFileStream
*/
protected $currentFileCount = 0;
+ /**
+ * List of Files
+ * @var array
+ */
+ protected $files = [];
+
/**
* @inheritdoc
* @param string|null $header File header
@@ -65,13 +71,31 @@ public function __construct($fileName, $header = null, $footer = null, $maxCount
}
}
+ /**
+ * Adds the given Filename to the internal Array
+ * @param $filename
+ */
+ protected function addFile($filename)
+ {
+ $this->files[] = $filename;
+ }
+
+ /**
+ * Returns the List of written Files
+ * @return array
+ */
+ public function getFileList()
+ {
+ return $this->files;
+ }
+
/**
* @inheritdoc
*/
protected function openHandle()
{
parent::openHandle();
-
+ $this->addFile($this->getFileName());
if ($this->header !== null) {
$this->write($this->header, false);
}
diff --git a/tests/FileStreamTest.php b/tests/FileStreamTest.php
index 36ec0b6..0c2a687 100644
--- a/tests/FileStreamTest.php
+++ b/tests/FileStreamTest.php
@@ -81,4 +81,33 @@ public function testPlaceholderValidation()
3
);
}
+
+
+ public function testFilestreamGathersListOfFilenames()
+ {
+ $stream = $this->prepareStreamToGenerateAmountOfFiles(3);
+
+ $this->assertCount(3, $stream->getFileList());
+ }
+
+ /**
+ * @param $amount
+ * @return FileStream
+ */
+ private function prepareStreamToGenerateAmountOfFiles($amount)
+ {
+ $stream = new FileStream(
+ $this->runtimeDir . '/sitemap{count}.xml',
+ '',
+ '',
+ $amount
+ );
+
+ foreach ($urls = range(0, $amount * $amount - $amount) as $url) {
+ $stream->write(
+ 'https://github.com?page' . $url . '' . PHP_EOL
+ );
+ }
+ return $stream;
+ }
}