/** * Checks whether the given class is supported for denormalization by this normalizer. * * @param mixed $data Data to denormalize from. * @param string $type The class to which the data should be denormalized. * @param string $format The format being deserialized from. * * @return bool */ public function supportsDenormalization($data, $type, $format = null) { if ($format == "xml" && $type == Amount::GetClassName()) { return true; } return false; }
/** * 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; }
private function denormaliseAmount(\ArrayAccess $array) { return $this->serializer->denormalize($array['amount'], Amount::GetClassName(), $this->format, $this->context); }