We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf400ca commit 8f6b115Copy full SHA for 8f6b115
src/AbstractValueObject.php
@@ -62,6 +62,12 @@ public function init($data): self
62
if (is_object($data)) {
63
$data = get_object_vars($data);
64
}
65
+
66
+ // if it is root element reset
67
+ if (property_exists($this, self::ROOT)) {
68
+ $data = [self::ROOT => $data];
69
+ }
70
71
// foreach get data
72
foreach ($data as $name => $item) {
73
$setter = "set" . ucfirst($name);
@@ -216,7 +222,7 @@ private static function transformBuildInType(ReflectionParameter $reflectionPara
216
222
217
223
218
224
// check null
219
- if (!$reflectionParameter->allowsNull() && empty($value)) {
225
+ if (!$reflectionParameter->allowsNull() && is_null($value)) {
220
226
throw new Exception("Wrong data type of property. Data can not be null");
221
227
228
0 commit comments