10 defined(
'JPATH_PLATFORM') or die;
32 protected $_errors = array();
42 public function __construct($properties = null)
44 if ($properties !== null)
46 $this->setProperties($properties);
58 public function __toString()
60 return get_class($this);
73 public function def($property, $default = null)
75 $value = $this->
get($property, $default);
76 return $this->
set($property, $value);
91 public function get($property, $default = null)
93 if (isset($this->$property))
95 return $this->$property;
111 public function getProperties($public =
true)
113 $vars = get_object_vars($this);
116 foreach ($vars as $key => $value)
118 if (
'_' == substr($key, 0, 1))
140 public function getError($i = null, $toString =
true)
146 $error = end($this->_errors);
148 elseif (!array_key_exists($i, $this->_errors))
155 $error = $this->_errors[$i];
159 if ($error instanceof Exception && $toString)
161 return (
string) $error;
176 public function getErrors()
178 return $this->_errors;
191 public function set($property, $value = null)
193 $previous = isset($this->$property) ? $this->$property : null;
194 $this->$property = $value;
209 public function setProperties($properties)
211 if (is_array($properties) || is_object($properties))
213 foreach ((array) $properties as $k => $v)
235 public function setError($error)
237 array_push($this->_errors, $error);