. */ namespace SP\Domain\Common\Out; /** * Class DataModelBase */ abstract class DataModelBase { private array $properties; public function __construct(?array $properties = []) { foreach ($properties as $property => $value) { $this->{$property} = $value; } } /** * @param string $name * * @return mixed|null */ final public function __get(string $name) { if (property_exists($this, $name)) { return $this->{$name}; } return $this->properties[$name] ?? null; } final public function __set(string $name, mixed $value = null): void { if (is_numeric($value)) { $value = (int)$value; } if (property_exists($this, $name)) { $this->{$name} = $value; } else { $this->properties[$name] = $value; } } final public function __isset(string $name): bool { return property_exists($this, $name) || isset($this->properties[$name]); } }