Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
0
 public function testGetSetOutputDirWithDefaultValue()
 {
     $config = new ExportSettings();
     $newOutputDir = '/path/to/directory';
     $this->assertNotNull($config->getOutputDir());
     $this->assertNotSame($newOutputDir, $config->getOutputDir());
     $config->setOutputDir($newOutputDir);
     $this->assertSame($newOutputDir, $config->getOutputDir());
 }