/**
  * 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);
     $fraudFilterRule = new FraudFilterRule();
     $fraudFilterRule->setId($data['@id']);
     $fraudFilterRule->setName($data['@name']);
     $fraudFilterRule->setAction($data['action']);
     return $fraudFilterRule;
 }
 private function denormaliseFraudFilter(\ArrayAccess $array)
 {
     $fraudFilterData = $array['fraudresponse'];
     if (!isset($fraudFilterData) || !is_array($fraudFilterData)) {
         return null;
     }
     $data = new SafeArrayAccess($fraudFilterData);
     $ffr = new FraudFilter();
     $ffr->setMode($data['@mode']);
     $ffr->setResult($data['result']);
     $rules = $data['rules'];
     $ffrRules = new FraudFilterRuleCollection();
     if (!empty($rules)) {
         foreach ($rules as $currentRule) {
             // Ensure that $rules is an array of results
             if (isset($currentRule['@id'])) {
                 $currentRule = array(0 => $currentRule);
             }
             foreach ($currentRule as $ffrRule) {
                 $ffrRule = new SafeArrayAccess($ffrRule);
                 $tmpRule = new FraudFilterRule();
                 $tmpRule->setId($ffrRule['@id']);
                 $tmpRule->setName($ffrRule['@name']);
                 $tmpRule->setAction($ffrRule['action']);
                 $ffrRules->add($tmpRule);
             }
         }
         $ffr->setRules($ffrRules);
     }
     return $ffr;
 }