Skip to content

Commit 874841a

Browse files
committed
Refactor, change from continue to break in switch; adding empty analyseUNH method (TODO)
1 parent bf67d5a commit 874841a

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/EDI/Parser.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,21 @@ public function parse($file2)
109109
$this->analyseUNA(substr($line, 4, 6));
110110
}
111111
unset($file2[$x]);
112-
continue;
112+
break;
113113
case "UNB":
114114
if (!$this->unbChecked) {
115-
$this->analyseUNB(substr($line, 4));
115+
$line=$this->splitSegment($line);
116+
$this->analyseUNB($line[1]);
116117
}
117118
break;
119+
case "UNH":
120+
$line=$this->splitSegment($line);
121+
$this->analyseUNH($line);
122+
break;
123+
default:
124+
$line=$this->splitSegment($line);
125+
break;
118126
}
119-
$line=$this->splitSegment($line);
120127
}
121128
$this->parsedfile=array_values($file2); //reindex
122129
return $file2;
@@ -174,19 +181,31 @@ public function analyseUNA($line)
174181
}
175182
}
176183

177-
/**
184+
/**
178185
* Read UNA's characters definition
179-
* @param string $line : UNB definition line (without UNA tag). Example : :+.? '
186+
* @param string $line : UNB definition line (without UNB tag). Example : :+.? '
180187
*/
181-
public function analyseUNB($line)
188+
public function analyseUNB($encoding)
182189
{
183-
$encoding= substr($line, 0, 4);
190+
if (is_array($encoding)) {
191+
$encoding = $encoding[0];
192+
}
193+
$this->encoding = $encoding;
184194
if (isset($this->encodingToStripChars[$encoding])) { // we have a normed char set for your content
185195
$this->setStripRegex($this->encodingToStripChars[$encoding]);
186196
}
187197
$this->unbChecked = true;
188198
}
189199

200+
/**
201+
* Identify message type
202+
* @param string $line : UNH segment
203+
*/
204+
public function analyseUNH($line)
205+
{
206+
207+
}
208+
190209
//unwrap string splitting rows on terminator (if not escaped)
191210
private function unwrap($string)
192211
{

0 commit comments

Comments
 (0)