empModel = new EmployeeModel(); $this->empPolicyModel = new EmployeePolicyModel(); $this->claimModel = new TicketMasterModel(); } public function mapObjectType($data_to_map, $objectType) { $mapped_data = []; foreach ($objectType as $key => $value){ $mapped_data[$key] = $data_to_map[$value]; } return $mapped_data; } public function insertData($mapped_data, $type){ $model = $type == 1 ? "empModel" : "claimModel"; $this->$model->insert($mapped_data); } }