private function iterateChildren($data, $transacType)
 {
     foreach ($data as $key => $value) {
         if ($value == "REQUIRED") {
             throw new Exception("Missing Required Field: /{$key}/");
         } elseif (is_string($value) || is_numeric($value)) {
             $transacType->addChild($key, $value);
         } elseif (is_array($value)) {
             $node = $transacType->addChild($key);
             Obj2xml::iterateChildren($value, $node);
         }
     }
 }
Example #2
0
 private static function iterateChildren($data, $transacType)
 {
     foreach ($data as $key => $value) {
         if ($value === "REQUIRED") {
             throw new InvalidArgumentException("Missing Required Field: /{$key}/");
         } elseif (substr($key, 0, 12) === 'lineItemData') {
             $temp_node = $transacType->addChild('lineItemData');
             Obj2xml::iterateChildren($value, $temp_node);
         } elseif (substr($key, 0, -1) == 'detailTax') {
             $temp_node = $transacType->addChild('detailTax');
             Obj2xml::iterateChildren($value, $temp_node);
         } elseif (is_string($value) || is_numeric($value)) {
             $transacType->addChild($key, str_replace('&', '&', $value));
         } elseif (is_array($value)) {
             $node = $transacType->addChild($key);
             Obj2xml::iterateChildren($value, $node);
         }
     }
 }