File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
3
* EDIFACT Messages Encoder
4
- * (c)2016 Stefano Sabatini
4
+ * (c) 2018 Stefano Sabatini
5
5
*/
6
6
7
7
namespace EDI ;
@@ -12,6 +12,7 @@ class Encoder
12
12
private $ output = '' ;
13
13
private $ UNAActive = false ; // disable by default to preserve backward compatibility
14
14
private $ originalArray = [];
15
+ private $ wrap = true ; //when false adds a newline after each segment
15
16
16
17
/**
17
18
* @var string : component separator character (default :)
@@ -55,6 +56,8 @@ public function __construct($array = null, $wrap = true)
55
56
public function encode ($ arr , $ wrap = true , $ filterKeys = false )
56
57
{
57
58
$ this ->originalArray = $ arr ;
59
+ $ this ->wrap = $ wrap ;
60
+
58
61
$ edistring = '' ;
59
62
$ count = count ($ arr );
60
63
$ k = 0 ;
@@ -117,12 +120,16 @@ private function escapeValue($str)
117
120
public function get ()
118
121
{
119
122
if ($ this ->UNAActive ) {
120
- return "UNA " . $ this ->sepComp .
123
+ $ una = "UNA " . $ this ->sepComp .
121
124
$ this ->sepData .
122
125
$ this ->sepDec .
123
126
$ this ->symbRel .
124
127
$ this ->symbRep .
125
- $ this ->symbEnd . $ this ->output ;
128
+ $ this ->symbEnd ;
129
+ if ($ this ->wrap === false ) {
130
+ $ una .= "\n" ;
131
+ }
132
+ return $ una . $ this ->output ;
126
133
} else {
127
134
return $ this ->output ;
128
135
}
You can’t perform that action at this time.
0 commit comments