dataSet = $dataset;
$this->position = 0;
$this->dataView = $dataView;
}
public function count()
{
return count($this->dataSet);
}
public function setPosition($pos)
{
$this->position = $pos;
}
/**
* (PHP 5 >= 5.0.0)
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
public function current()
{
if ($this->dataView) {
return $this;
}
return $this->dataSet[$this->position];
}
/**
* (PHP 5 >= 5.0.0)
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next()
{
$this->position++;
}
/**
* (PHP 5 >= 5.0.0)
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
public function key()
{
return $this->position;
}
/**
* (PHP 5 >= 5.0.0)
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid()
{
return $this->position < count($this->dataSet);
}
/**
* (PHP 5 >= 5.0.0)
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind()
{
$this->position = 0;
}
public function __isset($name)
{
return $this->dataView->exists($this->dataSet[$this->position], $name);
}
public function __get($name)
{
return $this->dataView->get($this->dataSet[$this->position], $name);
}
public function __set($name, $value)
{
throw new Exception("Setting is currently not available for objects");
}
public function offsetExists($offset)
{
return count($this->dataSet) < $offset;
}
public function offsetGet($offset)
{
$res = new MonitoringObjectList($this->dataSet, $this->dataView);
$res->position = $offset;
return $res;
}
public function offsetSet($offset, $value)
{
// non mutable
}
public function offsetUnset($offset)
{
// non mutable
}
}