From 75d71dcf34fa8d4c0f4f4baa704cbd52e6931cae Mon Sep 17 00:00:00 2001 From: Garethp Date: Wed, 22 Jul 2015 11:38:06 +0200 Subject: [PATCH] Updating buildFromArray() --- src/API/Type.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/API/Type.php b/src/API/Type.php index c679a5c0..0d65c80c 100644 --- a/src/API/Type.php +++ b/src/API/Type.php @@ -85,11 +85,19 @@ public function castToExchange($value, $type) public static function buildFromArray($array) { + if (!is_array($array)) { + return $array; + } + if (!self::arrayIsAssoc($array)) { + foreach ($array as $key => $value) { + $array[$key] = self::buildFromArray($value); + } + return $array; } - $object = new self(); + $object = new static(); foreach ($array as $key => $value) { if (is_array($value)) { $value = self::buildFromArray($value);