@@ -181,7 +181,7 @@ public function process(array $data, array $rawSegments = null): string
181
181
182
182
$ idHeader = $ id . ' - ' . $ attributes ['name ' ];
183
183
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 ' ;
185
185
}
186
186
$ r [] = $ idHeader ;
187
187
$ r [] = ' ( ' . \wordwrap ($ attributes ['desc ' ], 75 , \PHP_EOL . ' ' ) . ') ' ;
@@ -210,7 +210,7 @@ public function process(array $data, array $rawSegments = null): string
210
210
$ codeElementId = $ d_sub_desc_attr ['id ' ];
211
211
$ line = ' [ ' . $ d_n . '] ' . $ d_detail ;
212
212
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 . ' ' ) ;
214
214
}
215
215
$ r [] = $ line ;
216
216
@@ -249,7 +249,19 @@ public function process(array $data, array $rawSegments = null): string
249
249
}
250
250
$ jsonelements [$ d_desc_attr ['name ' ]] = $ jsoncomposite ;
251
251
} 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 ;
253
265
$ r [] = $ l1 ;
254
266
$ r [] = $ l2 ;
255
267
$ jsonelements [$ d_desc_attr ['name ' ]] = $ detail ;
@@ -341,4 +353,4 @@ protected function readAttributesArray(\SimpleXMLElement $element): array
341
353
342
354
return $ attributes ;
343
355
}
344
- }
356
+ }
0 commit comments