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);
         }
     }
 }
예제 #2
0
파일: Obj2xml.php 프로젝트: huynp/Critical
 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);
         }
     }
 }