$propertyName; } } public function set(string $propertyName, $value): void { if (!property_exists($this, $propertyName)) { throw new \InvalidArgumentException("Property '{$propertyName}' does not exist."); } $sanitizedValue = getSanitizeValue($this, $propertyName, $value); $isValid = isValidValue($this, $propertyName, $sanitizedValue); if (!$isValid) { throw new \Exception(sprintf('Value "%s" is not a valid value for the "%s" property.', $value, $propertyName), 400); } $this->$propertyName = $sanitizedValue; } public function getModifiedProperties(): array { // Get the current state of the object $defaults = $this->getDefaults(); /** * Remove the primary key from the defaults array * Always assume that the primary key is modified */ if (array_key_exists(static::$primaryKey, $defaults)) { unset($defaults[static::$primaryKey]); } $properties = $this->getProperties(); // Compare the current state with the initial state and get the modified properties $modifiedProperties = arrayRecursiveDiff($defaults, $properties); // Return the modified properties return $modifiedProperties; } }