Пример #1
0
 /**
  * Dump this file to a stream-wrapped target
  *
  * @param string $target Stream-wrapped target
  * @param array $parameters Writer parameters
  * @return WriterInterface Writer instance
  * @throws InvalidWriterArgumentException If an invalid reader stream wrapper is given
  */
 public function toTarget($target, ...$parameters)
 {
     $writer = Tools::writer($target, $parameters);
     if ($writer instanceof WriterInterface) {
         $this->dump($writer);
         return $writer;
     }
     throw new InvalidArgumentException('Invalid writer stream wrapper', InvalidWriterArgumentException::INVALID_WRITER_STREAM_WRAPPER);
 }
Пример #2
0
 /**
  * Copy the source resource to a target resource
  *
  * @param string $target Stream wrapped target
  * @param array $parameters Writer parameters
  * @return WriterInterface Writer instance
  * @throws InvalidWriterArgumentException If the writer stream wrapper is invalid
  */
 public function toTarget($target, ...$parameters)
 {
     $writer = Tools::writer($target, $parameters);
     // If it's a file writer
     if ($writer instanceof FileWriter) {
         return $this->copyToFile($writer);
     }
     // If it's an in-memory writer
     if ($writer instanceof InMemoryWriter) {
         return $this->copyToInMemory($writer);
     }
     throw new InvalidArgumentException('Invalid writer stream wrapper', InvalidWriterArgumentException::INVALID_WRITER_STREAM_WRAPPER);
 }