55 lines
1.1 KiB
PHP
55 lines
1.1 KiB
PHP
<?php
|
|
|
|
class mfRouteros_Item implements ArrayAccess {
|
|
|
|
private $data = array();
|
|
|
|
public function __construct($response) {
|
|
$this->log=mfLoghandler::singleton();
|
|
if((is_array($response) && count($response)) || is_object($response)) {
|
|
foreach($response as $name => $value) {
|
|
$this->data[$name] = $value;
|
|
}
|
|
} else {
|
|
$this->data = false;
|
|
}
|
|
}
|
|
|
|
public function propcount() {
|
|
return count($this->data);
|
|
}
|
|
|
|
public function __get($name) {
|
|
if($this->data[$name]) {
|
|
return $this->data[$name];
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public function __toString() {
|
|
if($this->data['name']) {
|
|
return (string) $this->data['name'];
|
|
} else {
|
|
return "unnamed";
|
|
}
|
|
}
|
|
|
|
// array access interface
|
|
public function offsetExists($offset) {
|
|
return isset($this->data[$offset]);
|
|
}
|
|
|
|
public function offsetGet($offset) {
|
|
return $this->data[$offset];
|
|
}
|
|
|
|
public function offsetSet($offset, $value) {
|
|
$this->data[$offset] = $value;
|
|
}
|
|
|
|
public function offsetUnset($offset) {
|
|
unset($this->data[$offset]);
|
|
}
|
|
|
|
} |