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