diff --git a/src/Reader.php b/src/Reader.php index 50fe2274..d16d5c00 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -61,6 +61,14 @@ class Reader extends AbstractCsv implements Countable, IteratorAggregate, JsonSe */ protected $stream_filter_mode = STREAM_FILTER_READ; + /** + * @inheritdoc + */ + public static function createFromPath(string $path, string $open_mode = 'r', $context = null): AbstractCsv + { + return new static(Stream::createFromPath($path, $open_mode, $context)); + } + /** * Returns the header offset * diff --git a/tests/ReaderTest.php b/tests/ReaderTest.php index 090650e8..bfbb8406 100644 --- a/tests/ReaderTest.php +++ b/tests/ReaderTest.php @@ -349,4 +349,13 @@ public function testJsonSerialize() json_encode($reader) ); } + + /** + * @covers ::createFromPath + */ + public function testCreateFromPath() + { + $csv = Reader::createFromPath(__DIR__.'/data/foo_readonly.csv'); + $this->assertCount(1, $csv); + } } diff --git a/tests/data/foo_readonly.csv b/tests/data/foo_readonly.csv new file mode 100644 index 00000000..2f6d89fc --- /dev/null +++ b/tests/data/foo_readonly.csv @@ -0,0 +1 @@ +john,doe,john.doe@example.com