/** * This function will return a object filled with the data contained in the array given as parameter * */ public function fillObject($data) { $objecttype = inflector::getObjectfromcontext($this); $object = new $objecttype(); foreach ($data as $field => $value) { $objectfield = $this->getObjectfieldfor($field); $func = 'set' . ucfirst($objectfield); $object->{$func}($value); } return $object; }