public function __set($property, $value) { $method = 'set' . ucfirst($property); // for camelCase method name if (method_exists($this, $method)) { $reflection = new Reflection($this, $method); if (!$reflection->isPublic()) { throw new RuntimeException('The called method is not public.'); } } $this->data[$property] = $value; }