/**
  * Denormalizes data back into an object of the given class.
  *
  * @param mixed $data data to restore
  * @param string $class the expected class to instantiate
  * @param string $format format the given data was extracted from
  * @param array $context options available to the denormalizer
  *
  * @return object
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     if (is_null($data)) {
         return null;
     }
     $data = new SafeArrayAccess($data);
     $dccInfo = new DccInfo();
     $dccInfo->addDccProcessor($data['ccp'])->addType($data['type'])->addRate($data['rate'])->addRateType($data['ratetype']);
     $amount = $this->serializer->denormalize($data['amount'], Amount::GetClassName(), $format, $context);
     if ($amount != null) {
         $dccInfo->setAmount($amount);
     }
     return $dccInfo;
 }
 /**
  * Tests conversion of {@link PaymentRequest} to and from XML using setters for DCCInfo.
  */
 public function testPaymentRequestXmlDCCAuthSetters()
 {
     $request = new PaymentRequest();
     $request->setAccount(SampleXmlValidationUtils::DCC_AUTH_ACCOUNT);
     $request->setMerchantId(SampleXmlValidationUtils::DCC_AUTH_MERCHANT_ID);
     $card = new Card();
     $card->setExpiryDate(SampleXmlValidationUtils::DCC_AUTH_CARD_EXPIRY_DATE);
     $card->setNumber(SampleXmlValidationUtils::DCC_AUTH_CARD_NUMBER);
     $card->setType(SampleXmlValidationUtils::DCC_AUTH_CARD_TYPE);
     $card->setCardHolderName(SampleXmlValidationUtils::DCC_AUTH_CARD_HOLDER_NAME);
     $request->setCard($card);
     $dccAmount = new Amount();
     $dccAmount->setAmount(SampleXmlValidationUtils::DCC_AUTH_CH_AMOUNT);
     $dccAmount->setCurrency(SampleXmlValidationUtils::DCC_AUTH_CH_CURRENCY);
     $dccInfo = new DccInfo();
     $dccInfo->setDccProcessor(SampleXmlValidationUtils::DCC_AUTH_CCP);
     $dccInfo->setRate(SampleXmlValidationUtils::DCC_AUTH_RATE);
     $dccInfo->setAmount($dccAmount);
     $request->setDccInfo($dccInfo);
     $amount = new Amount();
     $amount->setAmount(SampleXmlValidationUtils::DCC_AUTH_AMOUNT);
     $amount->setCurrency(SampleXmlValidationUtils::DCC_AUTH_CURRENCY);
     $request->setAmount($amount);
     $autoSettle = new AutoSettle();
     $autoSettle->setFlag(SampleXmlValidationUtils::$AUTO_SETTLE_FLAG->getFlag());
     $request->setAutoSettle($autoSettle);
     $request->setTimeStamp(SampleXmlValidationUtils::DCC_AUTH_TIMESTAMP);
     $request->setOrderId(SampleXmlValidationUtils::DCC_AUTH_ORDER_ID);
     $request->setHash(SampleXmlValidationUtils::DCC_AUTH_REQUEST_HASH);
     // convert to XML
     $xml = $request->toXml();
     // Convert from XML back to PaymentRequest
     /* @var PaymentRequest $fromXmlRequest */
     $fromXmlRequest = new PaymentRequest();
     $fromXmlRequest = $fromXmlRequest->fromXml($xml);
     SampleXmlValidationUtils::checkUnmarshalledDccAuthLookUpPaymentRequest($fromXmlRequest, $this);
 }