Completed
Push — master ( 26e69a...ab0b77 )
by Robin
03:27
created

Mt940   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 7
Bugs 1 Features 1
Metric Value
wmc 4
c 7
b 1
f 1
lcom 1
cbo 2
dl 0
loc 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 20 4
1
<?php
2
3
namespace Kingsquare\Parser\Banking;
4
5
use Kingsquare\Parser\Banking;
6
7
/**
8
 * @author Kingsquare ([email protected])
9
 * @license http://opensource.org/licenses/MIT MIT
10
 */
11
class Mt940 extends Banking
12
{
13
    /** @var Banking\Mt940\Engine */
14
    protected $engine;
15
16
    /** @var bool */
17
    public static $removeIBAN = true; // defaults to true for BC
18
19
    /**
20
     * Parse the given string into an array of Banking\Statement objects.
21
     *
22
     * @param string               $string
23
     * @param Banking\Mt940\Engine $engine
24
     *
25
     * @return \Kingsquare\Banking\Statement[]
26
     */
27
    public function parse($string, Banking\Mt940\Engine $engine = null)
28
    {
29
        if (!empty($string)) {
30
            // load engine
31
            if ($engine === null) {
32
                $engine = Banking\Mt940\Engine::__getInstance($string);
33
            }
34
35
            $this->engine = $engine;
36
37
            if ($this->engine instanceof Banking\Mt940\Engine) {
38
                // parse using the engine
39
                $this->engine->loadString($string);
40
41
                return $this->engine->parse();
42
            }
43
        }
44
45
        return [];
46
    }
47
}
48