From 278ef46998d000d84af2ad76d12aea2dca733254 Mon Sep 17 00:00:00 2001 From: Eric Richer Date: Wed, 26 Jun 2024 15:56:47 -0400 Subject: [PATCH] To fix #51 Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- src/Mapper/UserHydrator.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; }