From 43e3daf7f226d1fa9fb6b2d732f22b5354202bee Mon Sep 17 00:00:00 2001 From: Paul Olthof Date: Sun, 27 Sep 2015 14:29:57 +0200 Subject: [PATCH] Parser for SNS bank. Also with overrule for sanitizeAccount as 9 number banking is not used anymore. --- src/Parser/Banking/Mt940/Engine/Sns.php | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Parser/Banking/Mt940/Engine/Sns.php diff --git a/src/Parser/Banking/Mt940/Engine/Sns.php b/src/Parser/Banking/Mt940/Engine/Sns.php new file mode 100644 index 0000000..bc3cd75 --- /dev/null +++ b/src/Parser/Banking/Mt940/Engine/Sns.php @@ -0,0 +1,73 @@ +getCurrentTransactionData(), $results) + && !empty($results[1]) + ) { + return $this->sanitizeAccount($results[1]); + } + + return ''; + } + + protected function parseTransactionAccountName() + { + $results = []; + if (preg_match('/^:86:\s?[A-z\d]+\s(.*?)$/im', $this->getCurrentTransactionData(), $results) + && !empty($results[1]) + ) { + return strtoupper($this->sanitizeAccountName($results[1])); + } + + return ''; + } + + protected function parseTransactionDescription() + { + $results = []; + if (preg_match_all('/[\n]:86:(.*?)(?=\n(:6(1|2))|$)/s', $this->getCurrentTransactionData(), $results) + && !empty($results[1]) + ) { + $this->filterMetaDataFromDescription($results); + + return $this->sanitizeDescription(implode(PHP_EOL, $results[1])); + } + + return ''; + } + + private function filterMetaDataFromDescription(&$results) + { + $lines = explode("\r\n", $results[1][0]); + unset($lines[0]); + unset($lines[1]); + $results[1][0] = implode("\r\n", $lines); + } + +}