diff --git a/template/types/properties/methods/default.php b/template/types/properties/methods/default.php index 737f1a40..e93d95ca 100644 --- a/template/types/properties/methods/default.php +++ b/template/types/properties/methods/default.php @@ -197,7 +197,46 @@ public function getSetterName(); ?>( = $; return $this; } - + + /** + + + * + + * @param getValueFHIRType()->getFullyQualifiedClassName(true); ?>[] $ + + * @return static + */ + public function set(array $ = []): self + { + if ([] !== $this->) { + $this->_trackValuesRemoved(count($this->)); + $this-> = []; + } + if ([] === $) { + return $this; + } + foreach($ as $v) { + if (is_object($v)) { + if ($v instanceof getValueFHIRType()->getClassName(); ?>) { + $this->getSetterName(); ?>($v); + } else { + throw new \InvalidArgumentException(sprintf( + 'getClassName(); ?> - Field "" must be an array of objects implementing getValueFHIRType()->getClassName(); ?>, object of type %s seen', + get_class($v) + )); + } + } else { + throw new \InvalidArgumentException(sprintf( + 'getClassName(); ?> - Unable to set value for field "" from value: %s', + json_encode($v) + )); + } + } + return $this; + } +