Example #1
0
 /**
  * @throws Exception\EmptyHeadersException
  * @throws Exception\InvalidArgumentTypeException
  * @throws Exception\OutputPathNotWritableException
  */
 public function validateOutput()
 {
     $headers = $this->config->getHeaders();
     if (empty($headers)) {
         throw new Exception\EmptyHeadersException();
     }
     if (!is_writable($this->config->getOutputDir())) {
         throw new Exception\OutputPathNotWritableException();
     }
     if (!is_string($this->config->getFilename())) {
         throw new Exception\InvalidArgumentTypeException();
     }
     $data = $this->config->getData();
     if (empty($data)) {
         throw new Exception\DataNotFoundException();
     }
 }
Example #2
0
 /**
  * Saves export output under specified filepath without downloading.
  * Proxied via __call() method
  * @param AdapterInterface $adapter
  */
 protected function save(AdapterInterface $adapter)
 {
     $output = $adapter->output();
     $filename = $this->config->getFilename() . $adapter->getExtension();
     $filepath = implode(DIRECTORY_SEPARATOR, [$this->config->getOutputDir(), $filename]);
     $file = fopen($filepath, 'wb');
     fwrite($file, $output);
     fclose($file);
 }
 public function testGetSetFilenameWithDefaultValue()
 {
     $config = new ExportSettings();
     $newFilename = 'new_output_filename';
     $this->assertNotNull($config->getFilename());
     $this->assertNotSame($newFilename, $config->getFilename());
     $config->setFilename($newFilename);
     $this->assertSame($newFilename, $config->getFilename());
 }