This repository was archived by the owner on Nov 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankCSV.class.php
More file actions
59 lines (47 loc) · 1.28 KB
/
BankCSV.class.php
File metadata and controls
59 lines (47 loc) · 1.28 KB
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
<?php
class BankCSV {
const TYPE_UNKNOWN = 0;
const TYPE_COBA = 1;
const TYPE_DIBA = 2;
const TYPE_SPK_CSV_GENERIC = 3;
const TYPE_SPK_CSV_CAMT = 4;
const TYPE_SPK_CSV_MT940 = 5;
const TYPE_SPK_MT940 = 6;
const TYPE_SPK_CAMT52 = 7;
public function __construct() {
}
/**
* Parse CSV from file
*
* String $filename the full path to the filename
*/
public function parseCSV($filename, $type = self::TYPE_UNKNOWN) {
if($type === self::TYPE_UNKNOWN || $type === null) $type = $this->getTypeByFilename($filename);
var_dump($type);
}
public function getTypeByFilename($filename) {
$basename = basename($filename);
$type = self::TYPE_UNKNOWN;
if(preg_match("/^Umsaetze_KtoNr(.*)\.csv$/i",$basename)) {
// CoBa
$type = self::TYPE_COBA;
}
else if(preg_match("/^Umsatzanzeige_(.*)\.csv$/i",$basename)) {
// DiBa
$type = self::TYPE_DIBA;
}
else if(preg_match("/^\d{8}\-(.*)\-umsatz\.csv$/i",$basename)) {
// SPK CSV-CAMT oder CSV-MT940
$type = self::TYPE_SPK_CSV_GENERIC;
}
else if(preg_match("/^\d{8}\-(.*)\-umsMT940\.txt$/i",$basename)) {
// SPK MT940
$type = self::TYPE_SPK_MT940;
}
else if(preg_match("/^\d{8}\-\d{8}\-(.*)\-camt52Booked\.zip$/i",$basename)) {
// SPK CAMT52
$type = self::TYPE_SPK_CAMT52;
}
return $type;
}
}