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:
1 parent
e8693834a0
commit
4a9d0398ad
6 files changed
+124
-19
No files matched your search
@@ -22,7 +22,20 @@ class WriterEntityFactory
|
||||
*/
|
||||
public static function createWriter($writerType)
|
||||
{
|
||||
return (new WriterFactory())->create($writerType);
|
||||
return WriterFactory::create($writerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates an instance of the appropriate writer, given the extension of the file to be written
|
||||
*
|
||||
* @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 WriterInterface
|
||||
*/
|
||||
public static function createWriterFromFile(string $path)
|
||||
{
|
||||
return WriterFactory::createFromFile($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user