Skip to content

Commit 6e3aeb7

Browse files
committed
Recognise service segments in Interpreter
1 parent 5b005a4 commit 6e3aeb7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/EDI/Interpreter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private function processXmlSegment($elm, $message, &$segmentIdx, &$array, &$erro
176176
if (!isset($array[$jsonMessage['key']])) {
177177
$array[$jsonMessage['key']] = $jsonMessage['value'];
178178
} else {
179-
if (isset($array[$jsonMessage['key']]['segmentCode'])) {
179+
if (isset($array[$jsonMessage['key']]['segmentCode']) || $jsonMessage['key'] === 'UnrecognisedType') {
180180
$temp = $array[$jsonMessage['key']];
181181
$array[$jsonMessage['key']] = [];
182182
$array[$jsonMessage['key']][] = $temp;
@@ -202,13 +202,12 @@ private function processXmlSegment($elm, $message, &$segmentIdx, &$array, &$erro
202202
*
203203
* @param $segment
204204
*/
205-
private function processSegment($segment, $xmlMap, $segmentIdx, &$errors = null)
205+
private function processSegment($segment, &$xmlMap, $segmentIdx, &$errors = null)
206206
{
207207
$id = $segment[0];
208208

209209
$jsonsegment = [];
210210
if (isset($xmlMap[$id])) {
211-
212211
$attributes = $xmlMap[$id]['attributes'];
213212
$details_desc = $xmlMap[$id]['details'];
214213

@@ -267,10 +266,13 @@ private function processSegment($segment, $xmlMap, $segmentIdx, &$errors = null)
267266
$jsonsegment['key'] = $attributes['name'];
268267
$jsonsegment['value'] = $jsonelements;
269268

269+
} elseif ($xmlMap !== $this->xmlSvc) {
270+
$jsonsegment = $this->processSegment($segment, $this->xmlSvc, $segmentIdx, $errors);
270271
} else {
271272
$jsonsegment['key'] = 'UnrecognisedType';
272273
$jsonsegment['value'] = $segment;
273274
}
275+
274276
return $jsonsegment;
275277
}
276278

0 commit comments

Comments
 (0)