private function isSatisfiedFormat(Format $format, LoggerInterface $logger = null) { if (empty($this->formats)) { return true; } foreach ($this->formats as $formatId) { if ($formatId == $format->getId()) { return true; } } if ($logger) { $logger->debug("Storage does not meet Preconditions due to format restriction. Was {$format}, should be one of " . implode(',', $this->formats)); } return false; }
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; }