Browse Source

added constraints check for dbo deserialization

develop
Robin Thoni 8 years ago
parent
commit
f58243595b
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      src/Utils/Dbo/LuDbo.php

+ 9
- 8
src/Utils/Dbo/LuDbo.php View File

128
             $doc = $parser->parse();
128
             $doc = $parser->parse();
129
             $type = is_null($doc) ? null : $doc->getType();
129
             $type = is_null($doc) ? null : $doc->getType();
130
 
130
 
131
+            $value = null;
131
             if (isset($json[$name])) {
132
             if (isset($json[$name])) {
132
                 $value = static::deserializeValue($json[$name], $type);
133
                 $value = static::deserializeValue($json[$name], $type);
133
                 $property->setAccessible(true);
134
                 $property->setAccessible(true);
134
                 $property->setValue($dbo, $value);
135
                 $property->setValue($dbo, $value);
135
-                
136
-                if ($doc->isNotNull() && is_null($value)) {
137
-                    throw new LuDboConstraintException("Field '" . $name . "' can not be null");
138
-                }
136
+            }
139
 
137
 
140
-                if (!is_null($doc) && !is_null($value)) {
141
-                    foreach ($doc->getConstraints() as $constraint) {
142
-                        call_user_func_array([$value, $constraint->getMethod()], $constraint->getArguments());
143
-                    }
138
+            if ($doc->isNotNull() && is_null($value)) {
139
+                throw new LuDboConstraintException("Field '" . $name . "' can not be null");
140
+            }
141
+
142
+            if (!is_null($doc) && !is_null($value)) {
143
+                foreach ($doc->getConstraints() as $constraint) {
144
+                    call_user_func_array([$value, $constraint->getMethod()], $constraint->getArguments());
144
                 }
145
                 }
145
             }
146
             }
146
         }
147
         }

Loading…
Cancel
Save