diff --git a/src/Preparable.php b/src/Preparable.php index 71292c8..e9fb789 100644 --- a/src/Preparable.php +++ b/src/Preparable.php @@ -19,36 +19,46 @@ protected function prepare($data, array $params) $key = $param['key']; $property = $param['property']; - if (is_array($data)) { - $array[$property] = isset($data[$key]) && !is_null($data[$key]) ? $data[$key] : null; + if ($key === 'ResolveData' && count($data->xpath('//ResolveData')) > 1) { + $resolves = $data->xpath('//ResolveData'); + + foreach($resolves as $index => $resolve) { + $resolves[$index] = array_map('strval', (array)$resolve); + } + + $array[$property] = $resolves; } else { - $array[$property] = isset($data->$key) && !is_null($data->$key) ? $data->$key : null; - } + if (is_array($data)) { + $array[$property] = isset($data[$key]) && !is_null($data[$key]) ? $data[$key] : null; + } else { + $array[$property] = isset($data->$key) && !is_null($data->$key) ? $data->$key : null; + } - if (isset($param['cast'])) { - switch ($param['cast']) { - case 'boolean': - $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? $array[$property] : $array[$property]->__toString()) : null; - $array[$property] = isset($array[$property]) && !is_null($array[$property]) ? ($array[$property] === 'true' ? true : false) : false; + if (isset($param['cast'])) { + switch ($param['cast']) { + case 'boolean': + $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? $array[$property] : $array[$property]->__toString()) : null; + $array[$property] = isset($array[$property]) && !is_null($array[$property]) ? ($array[$property] === 'true' ? true : false) : false; - break; - case 'float': - $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? floatval($array[$property]) : floatval($array[$property]->__toString())) : null; + break; + case 'float': + $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? floatval($array[$property]) : floatval($array[$property]->__toString())) : null; - break; - case 'string': - $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? $array[$property] : $array[$property]->__toString()) : null; + break; + case 'string': + $array[$property] = isset($array[$property]) ? (is_string($array[$property]) ? $array[$property] : $array[$property]->__toString()) : null; - break; - case 'array': - $array[$property] = (array)$array[$property]; + break; + case 'array': + $array[$property] = (array)$array[$property]; + } } - } - if (isset($param['callback'])) { - $callback = $param['callback']; + if (isset($param['callback'])) { + $callback = $param['callback']; - $array[$property] = $this->$callback($array[$property]); + $array[$property] = $this->$callback($array[$property]); + } } }