コード例 #1
0
 private function formatToWriter(Format $format, \SplFileInfo $file)
 {
     if ($format instanceof CsvFormat) {
         $writer = new CsvWriter($format->getDelimiter(), $format->getEnclosure(), fopen($file, 'a'), false, $format->isHeaderInFirstRow());
     } elseif ($format instanceof ExcelFormat) {
         $writer = new ExcelWriter($file->openFile('a'), $format->getActivesheet(), $format->getExceltype(), $format->isHeaderInFirstRow());
     } elseif ($format instanceof XmlFormat) {
         $writer = new XMLWriter($file->openFile('a'));
     } elseif ($format instanceof CompressedFormat) {
         throw new \LogicException('Not implemented!');
     } else {
         throw new InvalidConfigurationException('Cannot build writer. Unknown format: ' . $format);
     }
     return $writer;
 }