/** * @param array $userProfile * @param \ConsultBundle\Entity\UserInfo $user * * @return \ConsultBundle\Entity\User|\ConsultBundle\Entity\UserInfo|null */ private function populateUserFromAccounts(array $userProfile, UserInfo $user) { if (is_null($userProfile)) { return null; } if (empty($user)) { $user = new UserInfo(); } if (array_key_exists('dob', $userProfile)) { $dob = new \DateTime($userProfile['dob']); $age = $dob->diff(new \DateTime())->y; $user->setAge($age); } if (array_key_exists('gender', $userProfile)) { $user->setGender($userProfile['gender']); } if (array_key_exists('height', $userProfile)) { $user->setHeightInCms($userProfile['height']); } if (array_key_exists('weight', $userProfile)) { $user->setWeightInKgs($userProfile['weight']); } if (array_key_exists('blood_group', $userProfile)) { $user->setBloodGroup($userProfile['blood_group']); } if (array_key_exists('name', $userProfile)) { $user->setName($userProfile['name']); } if (array_key_exists('profile_picture', $userProfile)) { $user->setName($userProfile['profilePicture']); } return $user; }