data = $data; $this->updateData(); return $this; } public function getData() { return $this->data; } protected function updateData() { foreach ($this->data as $key => $value) { if (property_exists($this, $key)) { $this->$key = $value; } } $this->data = []; return $this; } }