/** * Getter * * @param string $name * @return mixed */ public function __get($name) { //if linked if (substr($name, 0, 6) == 'linked') { return $this->_linked(substr($name, 6)); } //else if formatted if (substr($name, 0, 9) == 'formatted') { return $this->_formatted(substr($name, 9)); } //else get from parent as attribute $result = parent::__get($name); //if not in the parent as an attribute if ($result === null) { //check if it is a Ucfirst call for a property $nName = preg_replace_callback('/^([A-Z])(\\S+)$/', function ($matches) { return strtolower($matches[1]) . $matches[2]; }, $name); //if so, get it if ($name !== $nName) { $result = ucfirst($this->{$nName}); } } //if not a Ucfirst call, if ($result === null) { //check if it is an UPPERCASE call $nName = preg_replace_callback('/^([A-Z]+)$/', function ($matches) { return strtolower($matches[1]); }, $name); //if so, get it if ($name !== $nName) { $result = strtoupper($this->{$nName}); } } //return the result whatever it is return $result; }