Update Reader/WriterEntityFactory

Add `WriterEntityFactory::createWriterFromFile`, working like `ReaderEntityFactory::createReaderFromFile` (guessing writer type from file name).
Use static functions when needed.
This commit is contained in:
Adrien Loison authored and Adrien Loison committed 2019-05-17 13:22:27 +02:00
1 parent e8693834a0
commit 4a9d0398ad
6 files changed
+124 -19

No files matched your search

@@ -13,25 +13,25 @@ class ReaderEntityFactory
/**
* This creates an instance of the appropriate reader, given the type of the file to be read
*
* @param string $readerType Type of the reader to instantiate
* @param string $readerType Type of the reader to instantiate
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @return ReaderInterface
*/
public static function createReader($readerType)
{
return (new ReaderFactory())->create($readerType);
return ReaderFactory::create($readerType);
}
/**
* Creates a reader by file extension
*
* @param string The path to the spreadsheet file. Supported extensions are .csv,.ods and .xlsx
* @param string $path The path to the spreadsheet file. Supported extensions are .csv, .ods and .xlsx
* @throws \Box\Spout\Common\Exception\IOException
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
* @return ReaderInterface
*/
public static function createReaderFromFile(string $path)
{
return (new ReaderFactory())->createFromFile($path);
return ReaderFactory::createFromFile($path);
}
}