diff --git a/src/HAB/Pica/Reader/PicaPlainReader.php b/src/HAB/Pica/Reader/PicaPlainReader.php index 0d5c0c0552b70038de0f5e9b22493a284755b3b3..3f428eb8ac7310650db183df24708a9ede605711 100644 --- a/src/HAB/Pica/Reader/PicaPlainReader.php +++ b/src/HAB/Pica/Reader/PicaPlainReader.php @@ -38,15 +38,15 @@ class PicaPlainReader extends Reader */ protected $_data; + /** - * Open the reader with input data. + * Open the reader with input stream. * - * @param string $data Input data + * @param resource|string $stream * @return void */ public function open ($data) { - parent::open($data); $this->_data = preg_split("/(?:\n\r|[\n\r])/", $data); } @@ -68,13 +68,12 @@ class PicaPlainReader extends Reader } /** - * Close the reader. + * Close reader. * * @return void */ public function close () { - parent::close(); $this->_data = null; } } diff --git a/src/HAB/Pica/Reader/PicaXmlReader.php b/src/HAB/Pica/Reader/PicaXmlReader.php index 7baa0cf020875ba7af904b0b484cdf3fb394645c..2d7bf93546ecf76a796eea6d84c81d975fb9fc55 100644 --- a/src/HAB/Pica/Reader/PicaXmlReader.php +++ b/src/HAB/Pica/Reader/PicaXmlReader.php @@ -53,18 +53,17 @@ class PicaXmlReader extends Reader } /** - * Prepare the reader for reading data. + * Open the reader with input stream. * - * @param string|resource $input + * @param resource|string $stream * @return void */ - public function open ($input) + public function open ($stream) { - if (is_resource($input)) { - $input = stream_get_contents($input); + if (is_resource($stream)) { + $stream = stream_get_contents($stream); } - $this->_xmlReader->XML($input); - parent::open($input); + $this->_xmlReader->xml($stream); } /** @@ -75,7 +74,6 @@ class PicaXmlReader extends Reader public function close () { $this->_xmlReader->close(); - parent::close(); } /** diff --git a/src/HAB/Pica/Reader/Reader.php b/src/HAB/Pica/Reader/Reader.php index 3484eca67244b196bd88d956787892d5eb752057..c202f37e4178f338b4617d28c7fb54e9172360b0 100644 --- a/src/HAB/Pica/Reader/Reader.php +++ b/src/HAB/Pica/Reader/Reader.php @@ -59,17 +59,19 @@ abstract class Reader {} /** - * Open the reader with input data. + * Open the reader with input stream. * + * @param resource|string $stream * @return void */ - public function open ($data) - { - if ($this->isOpen()) { - $this->close(); - } - $this->_isOpen = true; - } + abstract public function open ($stream); + + /** + * Close reader. + * + * @return void + */ + abstract public function close (); /** * Return next record in input data or FALSE if no more records. @@ -134,16 +136,6 @@ abstract class Reader $this->_filter = null; } - /** - * Close the reader. - * - * @return void - */ - public function close () - { - $this->_isOpen = false; - } - /** * Return true if the reader is open. *