_default, array_intersect_key($data, $this->_default)); $this->setAttribs($data); } public function __call($name, $args) { // getX methods if ('get' == substr($name,0,3)) { $property = substr($name, 3); $property[0] = strtolower($property[0]); if (isset($this->_data[$property])) return $this->_data[$property]; } } public function __set($name, $value) { $methodName = 'set' . ucfirst($name); if (method_exists($this, $methodName)) { return $this->$methodName($value); } if (array_key_exists($name, $this->_data)) return $this->_data[$name] = $value; } // Direct access to read data fields public function __get($name) { if (isset($this->_data[$name])) { return $this->_data[$name]; } } public function setAttribs(array $data) { foreach ($data as $key => $value) { $this->$key = $value; } } public function save() { $class = get_class($this); return Fiktiv_Data_Service::getInstance()->$class->save($this); } }