diff --git a/src/Mapper/UserHydrator.php b/src/Mapper/UserHydrator.php index 0305306..8b63417 100644 --- a/src/Mapper/UserHydrator.php +++ b/src/Mapper/UserHydrator.php @@ -67,15 +67,17 @@ public function hydrate(array $data, $object) } /** - * @param string $keyFrom - * @param string $keyTo + * @param string $keyFrom + * @param string $keyTo * @param array $array * @return array */ - protected function mapField($keyFrom, $keyTo, array $array) + protected function mapField(string $keyFrom, string $keyTo, array $array): array { - $array[$keyTo] = $array[$keyFrom]; - unset($array[$keyFrom]); + if (isset($array[$keyFrom])) { + $array[$keyTo] = $array[$keyFrom]; + unset($array[$keyFrom]); + } return $array; }