I'm writing a web application that requires meta data in some objects.
I'm trying to make to API as clean as possible. Would it be better to
have something like this:
class Mama {
public $meta;
function __construct(){
$this->meta = new Meta(array of data);
}
}
class Meta {
private $_values;
private $_modified;
function __contruct($array){
$this->_values = $array;
$this->_modified = FALSE;
}
function __set($name,$value){
$this->_modified = TRUE;
$this->_values[$name] = $value;
}
function __get ($name){
return $this->_values[$name];
}
}
-or-
class Mama {
public $_meta = array('name' => 'value';
function getMeta($name){
return $this->_meta[$name];
}
function setMeta($name,$value){
$this->_meta[$name] = $value;
}
function delMeta($name){
unset($this->_meta[$name])
}
}
I haven't done much OOP before, so I don't know what is "standard
practice." The project is for a small school newspaper, so it's more of
a programming excercise for me. What is more OOP correct?
-Pingveno