Skip to content
Snippets Groups Projects
Commit 5c879dc7 authored by David Maus's avatar David Maus
Browse files

Declare Reader::open(), Reader::close() abstract; accept stream or string

parent 98d9506d
No related branches found
No related tags found
No related merge requests found
...@@ -38,15 +38,15 @@ class PicaPlainReader extends Reader ...@@ -38,15 +38,15 @@ class PicaPlainReader extends Reader
*/ */
protected $_data; 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 * @return void
*/ */
public function open ($data) public function open ($data)
{ {
parent::open($data);
$this->_data = preg_split("/(?:\n\r|[\n\r])/", $data); $this->_data = preg_split("/(?:\n\r|[\n\r])/", $data);
} }
...@@ -68,13 +68,12 @@ class PicaPlainReader extends Reader ...@@ -68,13 +68,12 @@ class PicaPlainReader extends Reader
} }
/** /**
* Close the reader. * Close reader.
* *
* @return void * @return void
*/ */
public function close () public function close ()
{ {
parent::close();
$this->_data = null; $this->_data = null;
} }
} }
...@@ -53,18 +53,17 @@ class PicaXmlReader extends Reader ...@@ -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 * @return void
*/ */
public function open ($input) public function open ($stream)
{ {
if (is_resource($input)) { if (is_resource($stream)) {
$input = stream_get_contents($input); $stream = stream_get_contents($stream);
} }
$this->_xmlReader->XML($input); $this->_xmlReader->xml($stream);
parent::open($input);
} }
/** /**
...@@ -75,7 +74,6 @@ class PicaXmlReader extends Reader ...@@ -75,7 +74,6 @@ class PicaXmlReader extends Reader
public function close () public function close ()
{ {
$this->_xmlReader->close(); $this->_xmlReader->close();
parent::close();
} }
/** /**
......
...@@ -59,17 +59,19 @@ abstract class Reader ...@@ -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 * @return void
*/ */
public function open ($data) abstract public function open ($stream);
{
if ($this->isOpen()) { /**
$this->close(); * Close reader.
} *
$this->_isOpen = true; * @return void
} */
abstract public function close ();
/** /**
* Return next record in input data or FALSE if no more records. * Return next record in input data or FALSE if no more records.
...@@ -134,16 +136,6 @@ abstract class Reader ...@@ -134,16 +136,6 @@ abstract class Reader
$this->_filter = null; $this->_filter = null;
} }
/**
* Close the reader.
*
* @return void
*/
public function close ()
{
$this->_isOpen = false;
}
/** /**
* Return true if the reader is open. * Return true if the reader is open.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment