Commit 5c879dc7 authored by David Maus's avatar David Maus
Browse files

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

parent 98d9506d
......@@ -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;
}
}
......@@ -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();
}
/**
......
......@@ -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.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment