diff --git a/src/Model/Interpreter.php b/src/Model/Interpreter.php index f35070c..a9120ea 100644 --- a/src/Model/Interpreter.php +++ b/src/Model/Interpreter.php @@ -36,11 +36,11 @@ public function asInstance(Model $currentModel): void public function initialize(array $staticModel = []): Model { foreach ($this->parsedModel as $property) { - - // Custom Type? - if (!$property['isBuiltIn']) { + if (!$property['isBuiltIn'] && !isset($staticModel[$property['name']])) { $this->currentModel->{$property['name']} = new $property['type'](); + } elseif (!$property['isBuiltIn'] && $staticModel[$property['name']] instanceof $property['type']) { + $this->currentModel->{$property['name']} = $staticModel[$property['name']]; } // has default value? if (isset($property['defaultValue'])) { diff --git a/tests/Mocks/database.db b/tests/Mocks/database.db index a968576..a4f0443 100644 Binary files a/tests/Mocks/database.db and b/tests/Mocks/database.db differ diff --git a/tests/clover.xml b/tests/clover.xml index 7be7a12..942639a 100644 --- a/tests/clover.xml +++ b/tests/clover.xml @@ -1,6 +1,6 @@ - - + + @@ -585,76 +585,78 @@ - + - + - - - - - + + + + + + - - - + + + - + - - - - - - - - + + + + + + + + - - - + + - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + + - - + + - - - - + + + + + @@ -1233,6 +1235,6 @@ - +