-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBankFactory.php
More file actions
52 lines (47 loc) · 1.54 KB
/
BankFactory.php
File metadata and controls
52 lines (47 loc) · 1.54 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
<?php
namespace moay\FintsDatabase\Bank;
/**
* Class BankFactory
* @package moay\FintsDatabase\Bank
*/
class BankFactory
{
/**
* Takes a raw institute from the json database and converts it into a Bank object
*
* @param $institute
* @return Bank
*/
public static function create($institute)
{
$bank = new Bank();
$fieldmap = [
'number' => 'setId',
'blz' => 'setBlz',
'name' => 'setName',
'location' => 'setLocation',
"organisation" => 'setOrganization',
'pinTanURL' => 'setPinTanUrl',
'protocol' => 'setFintsVersion',
"hbciDomain" => 'setHbciUrl',
"hbciAddress" => 'setHbciIp',
"hbciVersion" => 'setHbciVersion'
];
foreach ($fieldmap as $field => $setter) {
if (isset($institute->{$field}) && $institute->{$field} !== null) {
$bank->{$setter}($institute->{$field});
}
}
$supportedTechnologies = [];
foreach (["ddv","rdh1","rdh2","rdh3","rdh4","rdh5","rdh6","rdh7","rdh8","rdh9","rdh10","rah7","rah9","rah10"] as $tech) {
if (isset($institute->{$tech}) && $institute->{$tech } === true) {
$supportedTechnologies[] = $tech;
}
if (isset($institute->pinTanUrl) && $institute->pinTanUrl !== null) {
$supportedTechnologies[] = 'pinTan';
}
}
$bank->setSupportedTechnologies($supportedTechnologies);
return $bank;
}
}