public function __call($method, $args) { $accessor = substr($method, 0, 3); $magicKeys = array('set', 'get', 'uns', 'has'); if (substr($method, 0, 12) == 'getFormatted') { $key = Core_Model_Lib_String::camelize(substr($method, 12)); $data = $this->getData($key); if (preg_match('/^\\s*([0-9]+(\\.[0-9]+)?)\\s*$/', $data)) { return $this->formatPrice($data, !empty($args[0]) ? $args[0] : null); } elseif (preg_match('/(\\d){2,4}\\-(\\d){2}\\-(\\d){2}/', $data)) { return $this->formatDate($data, !empty($args[0]) ? $args[0] : null); } } if (in_array($accessor, $magicKeys)) { if (substr($method, 0, 7) == 'getOrig') { $key = Core_Model_Lib_String::camelize(substr($method, 7)); $method = $accessor . 'OrigData'; } else { $key = Core_Model_Lib_String::camelize(substr($method, 3)); $method = $accessor . 'Data'; } $value = isset($args[0]) ? $args[0] : null; return call_user_func(array($this, $method), $key, $value); } throw new Exception("Invalid method " . get_class($this) . "::" . $method . "(" . print_r($args, 1) . ")"); }
public function __call($method, $args) { $accessor = substr($method, 0, 3); $magicKeys = array('set', 'get', 'uns', 'has'); if (in_array($accessor, $magicKeys)) { $key = Core_Model_Lib_String::camelize(substr($method, 3)); $method = $accessor . 'Data'; $value = isset($args[0]) ? $args[0] : null; return call_user_func(array($this, $method), $key, $value); } return parent::__call($method, $args); }