-
Notifications
You must be signed in to change notification settings - Fork 59
/
Sns.php
88 lines (76 loc) · 2.13 KB
/
Sns.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Kingsquare\Parser\Banking\Mt940\Engine;
use Kingsquare\Parser\Banking\Mt940\Engine;
/**
* **CAUTION** This is an untested / experimental engine for SNS
*
*
* @package Kingsquare\Parser\Banking\Mt940\Engine
* @author Paul Olthof (hpolthof@gmail.com)
* @license http://opensource.org/licenses/MIT MIT
*/
class Sns extends Engine
{
/**
* returns the name of the bank
* @return string
*/
protected function parseStatementBank()
{
return 'SNS';
}
/**
* @override just return the unsanitized IBAN string
* @inheritdoc
*/
protected function sanitizeAccount($string)
{
return $string;
}
/**
* @inheritdoc
*/
protected function parseTransactionAccount()
{
$results = [];
/** @noinspection NotOptimalRegularExpressionsInspection */
if (preg_match('/^:86:\s?([A-z\d]+)\s/im', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
return $this->sanitizeAccount($results[1]);
}
return '';
}
/**
* @inheritdoc
*/
protected function parseTransactionAccountName()
{
$results = [];
/** @noinspection NotOptimalRegularExpressionsInspection */
if (preg_match('/^:86:\s?[A-z\d]+\s(.*?)$/im', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
return strtoupper($this->sanitizeAccountName($results[1]));
}
return '';
}
/**
* @override filter out the first two meta-data lines
* @inheritdoc
*/
protected function parseTransactionDescription()
{
$results = [];
if (preg_match_all('/[\n]:86:(.*?)(?=\n(:6([12]))|$)/s', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
// filter out meta data
$lines = explode("\r\n", $results[1][0]);
unset($lines[0], $lines[1]);
$results[1][0] = implode("\r\n", $lines);
return $this->sanitizeDescription(implode(PHP_EOL, $results[1]));
}
return '';
}
}