From 81c4d552e3e8ff1cfe06f2983e499482dfc1e61a Mon Sep 17 00:00:00 2001 From: Sinri Edogawa Date: Fri, 8 Mar 2019 13:54:13 +0800 Subject: [PATCH] Add Factory Methods for each type of writers, to provide better experience with correct PHPDoc in IDE. --- src/Spout/Writer/WriterFactory.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Spout/Writer/WriterFactory.php b/src/Spout/Writer/WriterFactory.php index 7588940..78a8208 100644 --- a/src/Spout/Writer/WriterFactory.php +++ b/src/Spout/Writer/WriterFactory.php @@ -45,4 +45,34 @@ class WriterFactory return $writer; } + + /** + * @return CSV\Writer + */ + public static function createCSVWriter() + { + $writer = new CSV\Writer(); + $writer->setGlobalFunctionsHelper(new GlobalFunctionsHelper()); + return $writer; + } + + /** + * @return XLSX\Writer + */ + public static function createXLSXWriter() + { + $writer = new XLSX\Writer(); + $writer->setGlobalFunctionsHelper(new GlobalFunctionsHelper()); + return $writer; + } + + /** + * @return ODS\Writer + */ + public static function createODSWriter() + { + $writer = new ODS\Writer(); + $writer->setGlobalFunctionsHelper(new GlobalFunctionsHelper()); + return $writer; + } }