Code Duplication    Length = 24-24 lines in 2 locations

src/RunOpenCode/Sax/StreamAdapter/DomDocumentAdapter.php 1 location

@@ 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

src/RunOpenCode/Sax/StreamAdapter/SimpleXmlAdapter.php 1 location

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