Code Duplication    Length = 9-11 lines in 9 locations

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

@@ 95-103 (lines=9) @@
92
     *
93
     * {@inheritdoc}
94
     */
95
    protected function parseTransactionValueTimestamp()
96
    {
97
        $results = [];
98
        if (preg_match('/^:61:([\d]{6})[C|D]/', $this->getCurrentTransactionData(), $results) && !empty($results[1])) {
99
            return $this->sanitizeTimestamp($results[1], 'ymd');
100
        }
101
102
        return 0;
103
    }
104
105
    /**
106
     * Overloaded: Rabo uses longer strings for accountnumbers.

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

@@ 71-81 (lines=11) @@
68
     *
69
     * {@inheritdoc}
70
     */
71
    protected function parseTransactionPrice()
72
    {
73
        $results = [];
74
        if (preg_match('/^:61:.*[CD][a-zA-Z]?([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
75
                && !empty($results[1])
76
        ) {
77
            return $this->sanitizePrice($results[1]);
78
        }
79
80
        return 0;
81
    }
82
83
    /**
84
     * Overloaded: Sparkasse can have the 3rd character of the currencyname after the C/D and an "R" for cancellation befor the C/D.
@@ 88-98 (lines=11) @@
85
     *
86
     * {@inheritdoc}
87
     */
88
    protected function parseTransactionDebitCredit()
89
    {
90
        $results = [];
91
        if (preg_match('/^:61:\d+R?([CD]).?\d+/', $this->getCurrentTransactionData(), $results)
92
                && !empty($results[1])
93
        ) {
94
            return $this->sanitizeDebitCredit($results[1]);
95
        }
96
97
        return '';
98
    }
99
100
    /**
101
     * Overloaded: Sparkasse use the Field 61 for cancellations

src/Parser/Banking/Mt940/Engine.php 5 locations

@@ 371-381 (lines=11) @@
368
     *
369
     * @return string
370
     */
371
    protected function parseTransactionAccount()
372
    {
373
        $results = [];
374
        if (preg_match('/^:86: ?([\d\.]+)\s/im', $this->getCurrentTransactionData(), $results)
375
                && !empty($results[1])
376
        ) {
377
            return $this->sanitizeAccount($results[1]);
378
        }
379
380
        return '';
381
    }
382
383
    /**
384
     * uses the 86 field to determine accountname of the transaction.
@@ 388-398 (lines=11) @@
385
     *
386
     * @return string
387
     */
388
    protected function parseTransactionAccountName()
389
    {
390
        $results = [];
391
        if (preg_match('/:86: ?[\d\.]+ (.+)/', $this->getCurrentTransactionData(), $results)
392
                && !empty($results[1])
393
        ) {
394
            return $this->sanitizeAccountName($results[1]);
395
        }
396
397
        return '';
398
    }
399
400
    /**
401
     * uses the 61 field to determine amount/value of the transaction.
@@ 405-415 (lines=11) @@
402
     *
403
     * @return float
404
     */
405
    protected function parseTransactionPrice()
406
    {
407
        $results = [];
408
        if (preg_match('/^:61:.*[CD]([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
409
                && !empty($results[1])
410
        ) {
411
            return $this->sanitizePrice($results[1]);
412
        }
413
414
        return 0;
415
    }
416
417
    /**
418
     * uses the 61 field to determine debit or credit of the transaction.
@@ 422-432 (lines=11) @@
419
     *
420
     * @return string
421
     */
422
    protected function parseTransactionDebitCredit()
423
    {
424
        $results = [];
425
        if (preg_match('/^:61:\d+([CD])\d+/', $this->getCurrentTransactionData(), $results)
426
                && !empty($results[1])
427
        ) {
428
            return $this->sanitizeDebitCredit($results[1]);
429
        }
430
431
        return '';
432
    }
433
434
    /**
435
     * Parses the Cancellation flag of a Transaction
@@ 503-513 (lines=11) @@
500
     *
501
     * @return string
502
     */
503
    protected function parseTransactionCode()
504
    {
505
        $results = [];
506
        if (preg_match('/^:61:.*?N(.{3}).*/', $this->getCurrentTransactionData(), $results)
507
                && !empty($results[1])
508
        ) {
509
            return trim($results[1]);
510
        }
511
512
        return '';
513
    }
514
515
    /**
516
     * @param string $string

src/Parser/Banking/Mt940/Engine/Knab.php 1 location

@@ 76-84 (lines=9) @@
73
    /**
74
     * @inheritdoc
75
     */
76
    protected function parseTransactionAccountName()
77
    {
78
        $results = [];
79
        if (preg_match('/NAAM: (.+)/', $this->getCurrentTransactionData(), $results)
80
                && !empty($results[1])
81
        ) {
82
            return trim($results[1]);
83
        }
84
    }
85
86
    /**
87
     * @inheritdoc