Skip to content

Commit 8f6b115

Browse files
author
František Mazura
committed
bug fixes
1 parent bf400ca commit 8f6b115

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/AbstractValueObject.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public function init($data): self
6262
if (is_object($data)) {
6363
$data = get_object_vars($data);
6464
}
65+
66+
// if it is root element reset
67+
if (property_exists($this, self::ROOT)) {
68+
$data = [self::ROOT => $data];
69+
}
70+
6571
// foreach get data
6672
foreach ($data as $name => $item) {
6773
$setter = "set" . ucfirst($name);
@@ -216,7 +222,7 @@ private static function transformBuildInType(ReflectionParameter $reflectionPara
216222
}
217223

218224
// check null
219-
if (!$reflectionParameter->allowsNull() && empty($value)) {
225+
if (!$reflectionParameter->allowsNull() && is_null($value)) {
220226
throw new Exception("Wrong data type of property. Data can not be null");
221227
}
222228

0 commit comments

Comments
 (0)