public function __call($method, $arguments)
{
$var = lcfirst(str_replace(['get', 'set', 'serialize'], '', $method));
$underscored = $this->underscore($var);
$camelized = $this->camelize($var);
$numericCamel = $this->underscore(preg_replace('/([a-z])([\\d])/', '$1_$2', $var));
$try = [$var, $camelized, $underscored, $numericCamel];
if (strncasecmp($method, 'get', 3) == 0) {
foreach ($try as $test) {
if ($this->has($test) && property_exists($this, $test)) {
return $this->{$test};
} elseif ($this->has($test)) {
return $this->_fields[$test];
}
}
}
if (strncasecmp($method, 'serialize', 9) == 0) {
$method = 'get' . substr($method, 9);
return $this->{$method}();
}
if (strncasecmp($method, 'set', 3) == 0) {
if ($this->has($var) && property_exists($this, $var)) {
$this->{$var} = $arguments[0];
} elseif ($this->has($underscored) && property_exists($this, $underscored)) {
$this->{$underscored} = $arguments[0];
} else {
$this->_fields[$var] = $arguments[0];
}
}
}