public function saveContactDetail(Doctor $doctor) { $contactIdsArray = array(); $contactNumberArray = \json_decode($doctor->getContactNumber(), true); if (\is_array($contactNumberArray)) { if (isset($contactNumberArray['country_code'])) { $contactDetail = new ContactDetail(); $contactDetail->setCountryCode(isset($contactNumberArray['country_code']) ? $contactNumberArray['country_code'] : NULL); $contactDetail->setAreaCode(isset($contactNumberArray['area_code']) ? $contactNumberArray['area_code'] : NULL); $contactDetail->setNumber($contactNumberArray['number']); $contactDetail->setType(ContactDetailTypes::PHONE); $doctor->addContactDetail($contactDetail); } else { foreach ($contactNumberArray as $each) { if ($each['number']) { $contactDetail = new ContactDetail(); $contactDetail->setNumber($each['number']); $contactDetail->setType($this->getContactDetailType($each['type'])); $doctor->addContactDetail($contactDetail); } } } } return $doctor; }