public function __get($key) { $method = 'get' . ucfirst($key); if (in_array($key, $this->getFields())) { return $this->{$method}(); } }