. */ 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 */ public function __get(string $name) { if (property_exists($this, $name)) { return $this->{$name}; } if (array_key_exists($name, $this->properties)) { return $this->properties[$name]; } return null; } public function __set(string $name, ?string $value = null): void { if (is_numeric($value)) { $value = (int)$value; } if (property_exists($this, $name)) { $this->{$name} = $value; } else { $this->properties[$name] = $value; } } }