From e2869fcf0a4f64132b989fd6223e3bbd3e7c78d3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 22 Jan 2009 18:48:52 +0100 Subject: Move NoticeWrapper to a generalized ArrayWrapper class We need to use array wrappers for other kinds of queries, so I generalized the NoticeWrapper and tested it in the Notice class. --- lib/arraywrapper.php | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 lib/arraywrapper.php (limited to 'lib/arraywrapper.php') diff --git a/lib/arraywrapper.php b/lib/arraywrapper.php new file mode 100644 index 000000000..ef0eeffa5 --- /dev/null +++ b/lib/arraywrapper.php @@ -0,0 +1,79 @@ +. + */ + +if (!defined('LACONICA')) { + exit(1); +} + +class ArrayWrapper +{ + var $_items = null; + var $_count = 0; + var $_i = -1; + + function __construct($items) + { + $this->_items = $items; + $this->_count = count($this->_items); + } + + function fetch() + { + if (!$this->_items) { + return false; + } + $this->_i++; + if ($this->_i < $this->_count) { + return true; + } else { + return false; + } + } + + function __set($name, $value) + { + $item =& $this->_items[$this->_i]; + $item->$name = $value; + return $item->$name; + } + + function __get($name) + { + $item =& $this->_items[$this->_i]; + return $item->$name; + } + + function __isset($name) + { + $item =& $this->_items[$this->_i]; + return isset($item->$name); + } + + function __unset($name) + { + $item =& $this->_items[$this->_i]; + unset($item->$name); + } + + function __call($name, $args) + { + $item =& $this->_items[$this->_i]; + return call_user_func_array(array($item, $name), $args); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf