| @@ 61-84 (lines=24) @@ | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function convert($xmlDocument) |
|
| 62 | { |
|
| 63 | /** |
|
| 64 | * @var \DOMDocument $xmlDocument |
|
| 65 | */ |
|
| 66 | if (class_exists($this->streamClass)) { |
|
| 67 | ||
| 68 | $stream = @fopen($this->options['stream'],'r+b'); |
|
| 69 | ||
| 70 | if (false === $stream) { |
|
| 71 | throw new StreamAdapterException(sprintf('Unable to acquire resource handler on "%s".', $this->options['stream'])); |
|
| 72 | } |
|
| 73 | ||
| 74 | fwrite($stream, $xmlDocument->saveXML($this->options['save_xml_options'])); |
|
| 75 | ||
| 76 | if (false === rewind($stream)) { |
|
| 77 | throw new StreamAdapterException('Unable to to rewind stream.'); |
|
| 78 | } |
|
| 79 | ||
| 80 | return new $this->streamClass($stream); |
|
| 81 | } |
|
| 82 | ||
| 83 | throw new RuntimeException(sprintf('Provided StreamInterface implementation "%s" is not available on this system.', $this->streamClass)); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| @@ 53-76 (lines=24) @@ | ||
| 50 | /** |
|
| 51 | * {@inheritdoc} |
|
| 52 | */ |
|
| 53 | public function convert($xmlDocument) |
|
| 54 | { |
|
| 55 | /** |
|
| 56 | * @var \SimpleXMLElement $xmlDocument |
|
| 57 | */ |
|
| 58 | if (class_exists($this->streamClass)) { |
|
| 59 | ||
| 60 | $stream = fopen($this->options['stream'],'r+b'); |
|
| 61 | ||
| 62 | if (false === $stream) { |
|
| 63 | throw new StreamAdapterException(sprintf('Unable to acquire resource handler on "%s".', $this->options['stream'])); |
|
| 64 | } |
|
| 65 | ||
| 66 | fwrite($stream, $xmlDocument->asXML()); |
|
| 67 | ||
| 68 | if (false === rewind($stream)) { |
|
| 69 | throw new StreamAdapterException('Unable to to rewind stream.'); |
|
| 70 | } |
|
| 71 | ||
| 72 | return new $this->streamClass($stream); |
|
| 73 | } |
|
| 74 | ||
| 75 | throw new RuntimeException(sprintf('Provided StreamInterface implementation "%s" is not available on this system.', $this->streamClass)); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||