From 9757fbb033c0303f1e437d56d543947d5478bd27 Mon Sep 17 00:00:00 2001 From: Roman Syroeshko Date: Sat, 23 Aug 2014 20:19:48 +0400 Subject: [PATCH] [FIXED] https://github.com/PHPOffice/PHPWord/issues/340 --- src/PhpWord/IOFactory.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index f3808f72..ab46b87e 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -10,12 +10,9 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Writer\WriterInterface; use PhpOffice\PhpWord\Reader\ReaderInterface; +use PhpOffice\PhpWord\Writer\WriterInterface; -/** - * IO factory - */ abstract class IOFactory { /** @@ -24,15 +21,16 @@ abstract class IOFactory * @param PhpWord $phpWord * @param string $name * @return WriterInterface - * @throws Exception + * @throws \PhpOffice\PhpWord\Exception\Exception */ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') { - if ($name !== 'WriterInterface' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') { + if ($name !== 'WriterInterface' && !in_array($name, array('ODText', 'RTF', 'Word2007', 'HTML', 'PDF'), true)) { throw new Exception("\"{$name}\" is not a valid writer."); } $fqName = "PhpOffice\\PhpWord\\Writer\\{$name}"; + return new $fqName($phpWord); }