Skip to content

Commit 053f8db

Browse files
committed
Integrating patches to Analyser received by email
1 parent e81f05b commit 053f8db

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/EDI/Analyser.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function process(array $data, array $rawSegments = null): string
181181

182182
$idHeader = $id . ' - ' . $attributes['name'];
183183
if($this->directory && $id !== 'UNB') {
184-
$idHeader .= ' http://www.unece.org/trade/untdid/' . strtolower($this->directory) . '/trsd/trsd' . strtolower($id) . '.htm';
184+
$idHeader .= ' https://service.unece.org/trade/untdid/' . strtolower($this->directory) . '/trsd/trsd' . strtolower($id) . '.htm';
185185
}
186186
$r[] = $idHeader;
187187
$r[] = ' (' . \wordwrap($attributes['desc'], 75, \PHP_EOL . ' ') . ')';
@@ -210,7 +210,7 @@ public function process(array $data, array $rawSegments = null): string
210210
$codeElementId = $d_sub_desc_attr['id'];
211211
$line = ' [' . $d_n . '] ' . $d_detail;
212212
if(isset($this->codes[(int)$codeElementId][$d_detail])){
213-
$line .= ' - ' . $this->codes[$codeElementId][$d_detail];
213+
$line .= ' - ' . \wordwrap($this->codes[$codeElementId][$d_detail], 69, \PHP_EOL . ' ');
214214
}
215215
$r[] = $line;
216216

@@ -249,7 +249,19 @@ public function process(array $data, array $rawSegments = null): string
249249
}
250250
$jsonelements[$d_desc_attr['name']] = $jsoncomposite;
251251
} else {
252-
$r[] = ' [' . $n . '] ' . $detail;
252+
$codeElementId = $d_desc_attr['id'];
253+
$line = ' [' . $n . '] ' . $detail;
254+
if(isset($this->codes[(int)$codeElementId][$detail])){
255+
/*
256+
* for retrieving code element description when first element of the segment
257+
* is a data element and not a composite one. Ex: NAD segment.
258+
* We rewrite also l1 line for adding 'id:' prefix before data element id.
259+
* It's just a cosmetic fix
260+
*/
261+
$line .= ' - ' . \wordwrap($this->codes[$codeElementId][$detail], 71, \PHP_EOL . ' ');
262+
$l1 = ' id: ' . $d_desc_attr['id'] . ' - ' . $d_desc_attr['name'];
263+
}
264+
$r[] = $line;
253265
$r[] = $l1;
254266
$r[] = $l2;
255267
$jsonelements[$d_desc_attr['name']] = $detail;
@@ -341,4 +353,4 @@ protected function readAttributesArray(\SimpleXMLElement $element): array
341353

342354
return $attributes;
343355
}
344-
}
356+
}

0 commit comments

Comments
 (0)