Exemplo n.º 1
0
 /**
  * 
  * @param mixed $file A path to a file or a FileOutputStream object
  * @param array $params
  */
 public function __construct($file, $params = null)
 {
     if (is_string($file)) {
         $file = new FileOutputStream($file);
     }
     if (!$file instanceof FileOutputStream) {
         throw new EyeInvalidArgumentException('$file must be a string or a FileOutputStream object.');
     }
     parent::__construct($file, $params);
 }
Exemplo n.º 2
0
 /**
  * @param SimpleXmlElement &$data
  * @param int $length
  * @throws EyeIOException
  */
 public function write(&$data, $length = null)
 {
     if (!$data instanceof SimpleXmlElement) {
         throw new EyeInvalidArgumentException('$data must be a SimpleXmlElement object.');
     }
     //using DOM to format output
     try {
         $dom = new DOMDocument('1.0');
         $dom->preserveWhiteSpace = false;
         $dom->loadXML($data->asXML());
         $dom->formatOutput = $this->formatOutput;
         $rawData = $dom->saveXml();
         parent::write($rawData, $length);
     } catch (DOMException $e) {
         throw new EyeIOException('Unable to write XML data.', 0, $e);
     }
 }