Skip to content

Commit aa1ac13

Browse files
committed
Merge pull request #16 from fruitl00p/version_bump
Version bump
2 parents 940f922 + b61e91f commit aa1ac13

19 files changed

+121
-114
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ cache:
77
- $HOME/.composer/cache
88

99
php:
10-
- 5.4
1110
- 5.5
1211
- 5.6
1312
- 7

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{ "name": "Robin Speekenbrink", "email": "robin@kingsquare.nl" }
1010
],
1111
"require": {
12-
"php": ">=5.4"
12+
"php": ">=5.5"
1313
},
1414
"require-dev": {
1515
"phpunit/phpunit": "4.4.*",

src/Banking/Statement.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Statement implements \JsonSerializable
1212
{
1313
private $bank = '';
1414
private $account = '';
15-
private $transactions = array();
15+
private $transactions = [];
1616
private $startPrice = 0.0;
1717
private $endPrice = 0.0;
1818
private $timestamp = 0;

src/Parser/Banking.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class Banking
1818
*/
1919
public function parse($string)
2020
{
21-
return array();
21+
return [];
2222
}
2323
}

src/Parser/Banking/Mt940.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,27 @@ class Mt940 extends Banking
2020
* Parse the given string into an array of Banking\Statement objects
2121
*
2222
* @param string $string
23+
* @param Banking\Mt940\Engine $engine
2324
*
2425
* @return \Kingsquare\Banking\Statement[]
2526
*/
26-
public function parse($string)
27+
public function parse($string, Banking\Mt940\Engine $engine = null)
2728
{
2829
if (!empty($string)) {
2930
// load engine
30-
$this->engine = Banking\Mt940\Engine::__getInstance($string);
31+
if ($engine === null) {
32+
$engine = Banking\Mt940\Engine::__getInstance($string);
33+
}
34+
35+
$this->engine = $engine;
36+
3137
if ($this->engine instanceof Banking\Mt940\Engine) {
3238
// parse using the engine
39+
$this->engine->loadString($string);
3340
return $this->engine->parse();
3441
}
3542
}
3643

37-
return array();
44+
return [];
3845
}
3946
}

src/Parser/Banking/Mt940/Engine.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function loadString($string)
8989
*/
9090
public function parse()
9191
{
92-
$results = array();
92+
$results = [];
9393
foreach ($this->parseStatementData() as $this->currentStatementData) {
9494
$statement = new Statement();
9595
if ($this->debug) {
@@ -145,10 +145,10 @@ protected function parseStatementData()
145145
*/
146146
protected function parseTransactionData()
147147
{
148-
$results = array();
148+
$results = [];
149149
preg_match_all('/^:61:(.*?)(?=^:61:|^-X{,3}$|\Z)/sm', $this->getCurrentStatementData(), $results);
150150

151-
return ((!empty($results[0])) ? $results[0] : array());
151+
return ((!empty($results[0])) ? $results[0] : []);
152152
}
153153

154154
/**
@@ -195,7 +195,7 @@ protected function parseStatementBank()
195195
*/
196196
protected function parseStatementAccount()
197197
{
198-
$results = array();
198+
$results = [];
199199
if (preg_match('/:25:([\d\.]+)*/', $this->getCurrentStatementData(), $results)
200200
&& !empty($results[1])
201201
) {
@@ -218,7 +218,7 @@ protected function parseStatementAccount()
218218
*/
219219
protected function parseStatementStartPrice()
220220
{
221-
$results = array();
221+
$results = [];
222222
if (preg_match('/:60F:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
223223
&& !empty($results[1])
224224
) {
@@ -234,7 +234,7 @@ protected function parseStatementStartPrice()
234234
*/
235235
protected function parseStatementEndPrice()
236236
{
237-
$results = array();
237+
$results = [];
238238
if (preg_match('/:62F:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
239239
&& !empty($results[1])
240240
) {
@@ -250,7 +250,7 @@ protected function parseStatementEndPrice()
250250
*/
251251
protected function parseStatementTimestamp()
252252
{
253-
$results = array();
253+
$results = [];
254254
if (preg_match('/:60F:[C|D](\d{6})*/', $this->getCurrentStatementData(), $results)
255255
&& !empty($results[1])
256256
) {
@@ -266,7 +266,7 @@ protected function parseStatementTimestamp()
266266
*/
267267
protected function parseStatementNumber()
268268
{
269-
$results = array();
269+
$results = [];
270270
if (preg_match('/:28C?:(.*)/', $this->getCurrentStatementData(), $results)
271271
&& !empty($results[1])
272272
) {
@@ -283,7 +283,7 @@ protected function parseStatementNumber()
283283
*/
284284
protected function parseTransactionAccount()
285285
{
286-
$results = array();
286+
$results = [];
287287
if (preg_match('/^:86: ?([\d\.]+)\s/im', $this->getCurrentTransactionData(), $results)
288288
&& !empty($results[1])
289289
) {
@@ -299,7 +299,7 @@ protected function parseTransactionAccount()
299299
*/
300300
protected function parseTransactionAccountName()
301301
{
302-
$results = array();
302+
$results = [];
303303
if (preg_match('/:86: ?[\d\.]+ (.+)/', $this->getCurrentTransactionData(), $results)
304304
&& !empty($results[1])
305305
) {
@@ -315,7 +315,7 @@ protected function parseTransactionAccountName()
315315
*/
316316
protected function parseTransactionPrice()
317317
{
318-
$results = array();
318+
$results = [];
319319
if (preg_match('/^:61:.*[CD]([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
320320
&& !empty($results[1])
321321
) {
@@ -331,7 +331,7 @@ protected function parseTransactionPrice()
331331
*/
332332
protected function parseTransactionDebitCredit()
333333
{
334-
$results = array();
334+
$results = [];
335335
if (preg_match('/^:61:\d+([CD])\d+/', $this->getCurrentTransactionData(), $results)
336336
&& !empty($results[1])
337337
) {
@@ -347,7 +347,7 @@ protected function parseTransactionDebitCredit()
347347
*/
348348
protected function parseTransactionDescription()
349349
{
350-
$results = array();
350+
$results = [];
351351
if (preg_match_all('/[\n]:86:(.*?)(?=\n(:6(1|2))|$)/s', $this->getCurrentTransactionData(), $results)
352352
&& !empty($results[1])
353353
) {
@@ -363,7 +363,7 @@ protected function parseTransactionDescription()
363363
*/
364364
protected function parseTransactionEntryTimestamp()
365365
{
366-
$results = array();
366+
$results = [];
367367
if (preg_match('/^:61:(\d{6})/', $this->getCurrentTransactionData(), $results)
368368
&& !empty($results[1])
369369
) {
@@ -379,7 +379,7 @@ protected function parseTransactionEntryTimestamp()
379379
*/
380380
protected function parseTransactionValueTimestamp()
381381
{
382-
$results = array();
382+
$results = [];
383383
if (preg_match('/^:61:(\d{6})/', $this->getCurrentTransactionData(), $results)
384384
&& !empty($results[1])
385385
) {
@@ -395,7 +395,7 @@ protected function parseTransactionValueTimestamp()
395395
*/
396396
protected function parseTransactionCode()
397397
{
398-
$results = array();
398+
$results = [];
399399
if (preg_match('/^:61:.*?N(.{3}).*/', $this->getCurrentTransactionData(), $results)
400400
&& !empty($results[1])
401401
) {
@@ -412,11 +412,11 @@ protected function parseTransactionCode()
412412
*/
413413
protected function sanitizeAccount($string)
414414
{
415-
static $crudeReplacements = array(
415+
static $crudeReplacements = [
416416
'.' => '',
417417
' ' => '',
418418
'GIRO' => 'P',
419-
);
419+
];
420420

421421
// crude IBAN to 'old' converter
422422
if (Mt940::$removeIBAN

src/Parser/Banking/Mt940/Engine/Abn.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function parseTransactionAccount()
3030
$results = parent::parseTransactionAccount();
3131

3232
if (empty($results)) {
33-
$giroMatch = $ibanMatch = array();
33+
$giroMatch = $ibanMatch = [];
3434
if (preg_match('/^:86:GIRO(.{9})/im', $this->getCurrentTransactionData(), $giroMatch)
3535
&& !empty($giroMatch[1])
3636
) {
@@ -58,7 +58,7 @@ protected function parseTransactionAccountName()
5858
return $results;
5959
}
6060

61-
$results = array();
61+
$results = [];
6262
if (preg_match('/:86:(GIRO|BGC\.)\s+[\d]+ (.+)/', $this->getCurrentTransactionData(), $results)
6363
&& !empty($results[2])
6464
) {
@@ -82,7 +82,7 @@ protected function parseTransactionAccountName()
8282
*/
8383
protected function parseTransactionEntryTimestamp()
8484
{
85-
$results = array();
85+
$results = [];
8686
if (preg_match('/^:61:\d{6}(\d{4})[C|D]/', $this->getCurrentTransactionData(), $results)
8787
&& !empty($results[1])
8888
) {

src/Parser/Banking/Mt940/Engine/Rabo.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function parseStatementBank()
2525
*/
2626
protected function parseTransactionAccount()
2727
{
28-
$results = array();
28+
$results = [];
2929
// SEPA MT940 Structured
3030
if (preg_match('/^:61:.*\n(.*?)(\n|\:8)/im', $this->getCurrentTransactionData(), $results)
3131
&& !empty($results[1])
@@ -47,7 +47,7 @@ protected function parseTransactionAccount()
4747
*/
4848
protected function parseTransactionAccountName()
4949
{
50-
$results = array();
50+
$results = [];
5151
// SEPA MT940 Structured
5252
if (preg_match('#/NAME/(.*?)/(REMI|ADDR)/#ms', $this->getCurrentTransactionData(), $results)
5353
&& !empty($results[1])
@@ -74,7 +74,7 @@ protected function parseTransactionAccountName()
7474
*/
7575
protected function parseTransactionEntryTimestamp()
7676
{
77-
$results = array();
77+
$results = [];
7878
if (preg_match('/^:60F:[C|D]([\d]{6})/m', $this->getCurrentStatementData(), $results) && !empty($results[1])) {
7979
return $this->sanitizeTimestamp($results[1], 'ymd');
8080
}
@@ -88,7 +88,7 @@ protected function parseTransactionEntryTimestamp()
8888
*/
8989
protected function parseTransactionValueTimestamp()
9090
{
91-
$results = array();
91+
$results = [];
9292
if (preg_match('/^:61:([\d]{6})[C|D]/', $this->getCurrentTransactionData(), $results) && !empty($results[1])) {
9393
return $this->sanitizeTimestamp($results[1], 'ymd');
9494
}

src/Parser/Banking/Mt940/Engine/Spk.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function parseStatementBank()
2929
*/
3030
protected function parseStatementStartPrice()
3131
{
32-
$results = array();
32+
$results = [];
3333
if (preg_match('/:60[FM]:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
3434
&& !empty($results[1])
3535
) {
@@ -45,7 +45,7 @@ protected function parseStatementStartPrice()
4545
*/
4646
protected function parseStatementTimestamp()
4747
{
48-
$results = array();
48+
$results = [];
4949
if (preg_match('/:60[FM]:[C|D](\d{6})*/', $this->getCurrentStatementData(), $results)
5050
&& !empty($results[1])
5151
) {
@@ -61,7 +61,7 @@ protected function parseStatementTimestamp()
6161
*/
6262
protected function parseStatementEndPrice()
6363
{
64-
$results = array();
64+
$results = [];
6565
if (preg_match('/:62[FM]:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
6666
&& !empty($results[1])
6767
) {
@@ -77,7 +77,7 @@ protected function parseStatementEndPrice()
7777
*/
7878
protected function parseTransactionPrice()
7979
{
80-
$results = array();
80+
$results = [];
8181
if (preg_match('/^:61:.*[CD].?([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
8282
&& !empty($results[1])
8383
) {
@@ -93,7 +93,7 @@ protected function parseTransactionPrice()
9393
*/
9494
protected function parseTransactionDebitCredit()
9595
{
96-
$results = array();
96+
$results = [];
9797
if (preg_match('/^:61:\d+R?([CD]).?\d+/', $this->getCurrentTransactionData(), $results)
9898
&& !empty($results[1])
9999
) {

src/Parser/Banking/Mt940/Engine/Triodos.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function parseStatementBank()
2727
*/
2828
protected function parseStatementAccount()
2929
{
30-
$results = array();
30+
$results = [];
3131
if (preg_match('#:25:TRIODOSBANK/([\d\.]+)#', $this->getCurrentStatementData(), $results) && !empty($results[1])
3232
) {
3333
return $this->sanitizeAccount($results[1]);

0 commit comments

Comments
 (0)