/** * 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); $amount = new Amount(); $amount->addAmount($data['#']); $amount->addCurrency($data['@currency']); return $amount; }
private function denormaliseAmount(\ArrayAccess $array) { $amountData = $array['amount']; if (is_null($amountData)) { return null; } $data = new SafeArrayAccess($amountData); $amount = new Amount(); $amount->addAmount($data['#']); $amount->addCurrency($data['@currency']); return $amount; }