$value) { $prop = ltrim($key, '_'); $method = sprintf("set%s", ucfirst( $prop )); if (method_exists($this, $method)) { [$this, $method]($value); } elseif (property_exists($this, $prop)) { $this->{$prop} = $value; } else { if (property_exists($this, 'data')) { if (isset($this->data[$key])) continue; if (strpos($key, '-') !== false) continue; $this->data[$key] = $value; } } } } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): self { $this->slug = $slug; return $this; } public function getData(): ?array { return $this->data; } }