Skip to content

Commit

Permalink
Support cast array
Browse files Browse the repository at this point in the history
  • Loading branch information
DyanGalih committed Jun 1, 2020
1 parent 87f5621 commit 881af9b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Tools/Lazy.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function copy(object $fromClass, object $toClass, int $option = se
foreach (get_object_vars($toClass) as $key => $value) {
if (property_exists($toClass, $key)) {
$propertyClass = self::_getVarValue($toClass, $key);
if(isset($fromClass->$key)){
if (isset($fromClass->$key)) {
$toClass->$key = self::castValue($propertyClass, $fromClass->$key);
}
}
Expand Down Expand Up @@ -195,9 +195,18 @@ private static function castValue($propertyClass, $from)
case "double":
$value = (double)$from;
break;
case "real":
$value = (real)$from;
break;
case "boolean":
$value = (boolean)$from;
break;
case "object":
$value = (object)$from;
break;
case "array":
$value = (array)$from;
break;
default :
$value = (string)$from;
break;
Expand Down

0 comments on commit 881af9b

Please sign in to comment.