File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11<?php
22/**
33 * EDIFACT Messages Encoder
4- * (c)2016 Stefano Sabatini
4+ * (c) 2018 Stefano Sabatini
55 */
66
77namespace EDI ;
@@ -12,6 +12,7 @@ class Encoder
1212 private $ output = '' ;
1313 private $ UNAActive = false ; // disable by default to preserve backward compatibility
1414 private $ originalArray = [];
15+ private $ wrap = true ; //when false adds a newline after each segment
1516
1617 /**
1718 * @var string : component separator character (default :)
@@ -55,6 +56,8 @@ public function __construct($array = null, $wrap = true)
5556 public function encode ($ arr , $ wrap = true , $ filterKeys = false )
5657 {
5758 $ this ->originalArray = $ arr ;
59+ $ this ->wrap = $ wrap ;
60+
5861 $ edistring = '' ;
5962 $ count = count ($ arr );
6063 $ k = 0 ;
@@ -117,12 +120,16 @@ private function escapeValue($str)
117120 public function get ()
118121 {
119122 if ($ this ->UNAActive ) {
120- return "UNA " . $ this ->sepComp .
123+ $ una = "UNA " . $ this ->sepComp .
121124 $ this ->sepData .
122125 $ this ->sepDec .
123126 $ this ->symbRel .
124127 $ this ->symbRep .
125- $ this ->symbEnd . $ this ->output ;
128+ $ this ->symbEnd ;
129+ if ($ this ->wrap === false ) {
130+ $ una .= "\n" ;
131+ }
132+ return $ una . $ this ->output ;
126133 } else {
127134 return $ this ->output ;
128135 }
You can’t perform that action at this time.
0 commit comments