@@ -39,6 +39,11 @@ class Interpreter
3939 'SG1 ' => [['TDT ' , '20 ' , 'XXX ' ]],
4040 ];
4141
42+ /**
43+ *
44+ */
45+ private $ patchFiles = true ;
46+
4247 /**
4348 * @var \SimpleXMLElement
4449 */
@@ -113,6 +118,11 @@ public function __construct(string $xmlMsg, array $xmlSeg, array $xmlSvc, array
113118 };
114119 }
115120
121+ public function togglePatching (bool $ flag )
122+ {
123+ $ this ->patchFiles = $ flag ;
124+ }
125+
116126 /**
117127 * Patch the error messages array
118128 *
@@ -305,7 +315,12 @@ private function splitMessages(&$parsed, &$errors): array
305315 ];
306316 }
307317 $ service ['UNZ ' ] = $ segment ;
308-
318+ if ($ this ->patchFiles && $ hasMessageDelimiters > 0 ) {
319+ $ segment = ['UNT ' , '0 ' , '1 ' ];
320+ $ hasMessageDelimiters --;
321+ $ tmpmsg [] = $ segment ;
322+ $ messages [] = $ tmpmsg ;
323+ }
309324 break ;
310325 case 'UNH ' :
311326 $ hasMessageDelimiters = 0 ;
@@ -416,7 +431,7 @@ private function processXmlGroup(\SimpleXMLElement $elm, array &$message, int &$
416431 ) {
417432 $ elmType = $ elm ['id ' ]->__toString ();
418433 $ fixed = false ;
419- if (isset ($ this ->groupTemplates [$ elmType ])) {
434+ if ($ this -> patchFiles && isset ($ this ->groupTemplates [$ elmType ])) {
420435 \array_splice ($ message , $ segmentIdx , 0 , $ this ->groupTemplates [$ elmType ]);
421436 $ fixed = true ;
422437 }
@@ -482,7 +497,7 @@ private function processXmlSegment(\SimpleXMLElement $elm, array &$message, int
482497 $ elmType = (string ) $ elm ['id ' ];
483498 }
484499
485- if (isset ($ this ->segmentTemplates [$ elmType ])) {
500+ if ($ this -> patchFiles && isset ($ this ->segmentTemplates [$ elmType ])) {
486501 $ jsonMessage = $ this ->processSegment ($ this ->segmentTemplates [$ elmType ], $ this ->xmlSeg , $ segmentIdx , $ errors );
487502 $ fixed = true ;
488503 $ this ->doAddArray ($ array , $ jsonMessage );
0 commit comments