22
33namespace EDI \Generator ;
44
5+ use EDI \Generator \Traits \Segments ;
6+
57/**
68 * Class Base
79 *
810 * @package EDI\Generator
911 */
1012class Base
1113{
14+ use Segments;
15+
1216 /** @var array */
1317 protected $ messageContent = [];
1418
1519 /** @var array */
1620 protected $ composed ;
1721
18- /** @var string */
19- protected $ sender ;
20-
21- /** @var string */
22- protected $ receiver ;
23-
2422 /** @var string */
2523 // protected $managingOrganisation = '89';
2624
@@ -33,7 +31,7 @@ public function addKeyToCompose($keyName)
3331 }
3432
3533 /**
36- * compose message by keys givven in an ordered array
34+ * compose message by keys given in an ordered array
3735 *
3836 * @param array $keys
3937 *
@@ -74,46 +72,6 @@ public function getComposed()
7472 return $ this ->composed ;
7573 }
7674
77- /**
78- * @return string
79- */
80- public function getSender ()
81- {
82- return $ this ->sender ;
83- }
84-
85- /**
86- * @param string $sender
87- *
88- * @return $this
89- */
90- public function setSender ($ sender )
91- {
92- $ this ->sender = $ sender ;
93-
94- return $ this ;
95- }
96-
97- /**
98- * @return string
99- */
100- public function getReceiver ()
101- {
102- return $ this ->receiver ;
103- }
104-
105- /**
106- * @param string $receiver
107- *
108- * @return $this
109- */
110- public function setReceiver ($ receiver )
111- {
112- $ this ->receiver = $ receiver ;
113-
114- return $ this ;
115- }
116-
11775 /**
11876 * Crop String to max char length
11977 *
@@ -151,86 +109,4 @@ protected function isAllowed($value, $array, $errorMessage = null)
151109 }
152110 }
153111
154- /**
155- * SEGMENT UTILITIES
156- */
157-
158- /**
159- * @param string, $functionCode
160- * @param $identifier
161- *
162- * @return array|bool
163- */
164- protected static function addRFFSegment ($ functionCode , $ identifier )
165- {
166- if (empty ($ identifier )) {
167- return false ;
168- }
169-
170- return [
171- 'RFF ' ,
172- [
173- $ functionCode ,
174- self ::maxChars ($ identifier , 35 ),
175- ],
176- ];
177- }
178-
179- /**
180- * @param string|\DateTime $date
181- * @param string $type
182- * @param int $formatQualifier
183- *
184- * @return array
185- * @throws EdifactException
186- * @see http://www.unece.org/trade/untdid/d96a/trsd/trsddtm.htm
187- */
188- protected static function addDTMSegment ($ date , $ type , $ formatQualifier = EdifactDate::DATE )
189- {
190- $ data = [];
191- $ data [] = (string ) $ type ;
192- if (!empty ($ date )) {
193- $ data [] = EdifactDate::get ($ date , $ formatQualifier );
194- $ data [] = (string ) $ formatQualifier ;
195- }
196-
197- return ['DTM ' , $ data ];
198- }
199-
200- /**
201- * @param $documentNumber
202- * @param $type
203- *
204- * @return array
205- */
206- public static function addBGMSegment ($ documentNumber , $ type )
207- {
208- return [
209- 'BGM ' ,
210- [
211- $ type ,
212- '' ,
213- '89 ' ,
214- ],
215- $ documentNumber ,
216- ];
217- }
218-
219- /**
220- * @param $qualifier
221- * @param $value
222- *
223- * @return array
224- */
225- public static function addMOASegment ($ qualifier , $ value )
226- {
227- return [
228- 'MOA ' ,
229- [
230- '' ,
231- (string ) $ qualifier ,
232- EdiFactNumber::convert ($ value ),
233- ],
234- ];
235- }
236112}
0 commit comments