Skip to content

Commit

Permalink
Remove substitution properties, use methods instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jschaedl committed Nov 6, 2016
1 parent 67d7182 commit a2423cb
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 199 deletions.
23 changes: 16 additions & 7 deletions library/IBAN/Rule/AbstractRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ abstract class AbstractRule
protected $instituteIdentification;
protected $bankAccountNumber;

protected $instituteIdentificationSubstitutions = array();
protected $bankAccountSubstitutions = array();

public function __construct($localeCode, $instituteIdentification, $bankAccountNumber)
{
$this->localeCode = $localeCode;
Expand All @@ -43,6 +40,16 @@ public function generateIban()
$this->normalizeBankAccountNumber();
}

protected function getInstituteIdentificationSubstitutions()
{
return [];
}

protected function getBankAccountSubstitutions()
{
return [];
}

protected function getNumericRepresentation($letterRepresentation)
{
$numericRepresentation = '';
Expand Down Expand Up @@ -110,15 +117,17 @@ private function normalizeBankAccountNumber()

private function substituteInstituteIdentifications()
{
if (array_key_exists($this->instituteIdentification, $this->instituteIdentificationSubstitutions)) {
$this->instituteIdentification = $this->instituteIdentificationSubstitutions[$this->instituteIdentification];
$instituteIdentificationSubstitutions = $this->getInstituteIdentificationSubstitutions();
if (array_key_exists($this->instituteIdentification, $instituteIdentificationSubstitutions)) {
$this->instituteIdentification = $instituteIdentificationSubstitutions[$this->instituteIdentification];
}
}

private function substituteBankAccountNumbers()
{
if (array_key_exists($this->bankAccountNumber, $this->bankAccountSubstitutions)) {
$this->bankAccountNumber = $this->bankAccountSubstitutions[$this->bankAccountNumber];
$bankAccountSubstitutions = $this->getBankAccountSubstitutions();
if (array_key_exists($this->bankAccountNumber, $bankAccountSubstitutions)) {
$this->bankAccountNumber = $bankAccountSubstitutions[$this->bankAccountNumber];
}
}
}
27 changes: 15 additions & 12 deletions library/IBAN/Rule/DE/Rule000400.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@

class Rule000400 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"135" => "990021440"
, "1111" => "6600012020"
, "1900" => "920019005"
, "7878" => "780008006"
, "8888" => "250030942"
, "9595" => "1653524703"
, "97097" => "13044150"
, "112233" => "630025819"
, "336666" => "6604058903"
, "484848" => "920018963"
);
protected function getBankAccountSubstitutions()
{
return array(
"135" => "990021440"
, "1111" => "6600012020"
, "1900" => "920019005"
, "7878" => "780008006"
, "8888" => "250030942"
, "9595" => "1653524703"
, "97097" => "13044150"
, "112233" => "630025819"
, "336666" => "6604058903"
, "484848" => "920018963"
);
}
}
15 changes: 9 additions & 6 deletions library/IBAN/Rule/DE/Rule000600.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

class Rule000600 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"1111111" => "20228888"
, "7777777" => "903286003"
, "34343434" => "1000506517"
, "70000" => "18180018"
);
protected function getBankAccountSubstitutions()
{
return array(
"1111111" => "20228888"
, "7777777" => "903286003"
, "34343434" => "1000506517"
, "70000" => "18180018"
);
}
}
73 changes: 38 additions & 35 deletions library/IBAN/Rule/DE/Rule000700.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,42 @@

class Rule000700 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"111" => "1115"
, "221" => "23002157"
, "1888" => "18882068"
, "2006" => "1900668508"
, "2626" => "1900730100"
, "3004" => "1900637016"
, "3636" => "23002447"
, "4000" => "4028"
, "4444" => "17368"
, "5050" => "73999"
, "8888" => "1901335750"
, "30000" => "9992959"
, "43430" => "1901693331"
, "46664" => "1900399856"
, "55555" => "34407379"
, "102030" => "1900480466"
, "151515" => "57762957"
, "222222" => "2222222"
, "300000" => "9992959"
, "333333" => "33217"
, "414141" => "92817"
, "606060" => "91025"
, "909090" => "90944"
, "2602024" => "5602024"
, "3000000" => "9992959"
, "7777777" => "2222222"
, "8090100" => "38901"
, "14141414" => "43597665"
, "15000023" => "15002223"
, "15151515" => "57762957"
, "22222222" => "2222222"
, "200820082" => "1901783868"
, "222220022" => "2222222"
);
protected function getBankAccountSubstitutions()
{
return array(
"111" => "1115"
, "221" => "23002157"
, "1888" => "18882068"
, "2006" => "1900668508"
, "2626" => "1900730100"
, "3004" => "1900637016"
, "3636" => "23002447"
, "4000" => "4028"
, "4444" => "17368"
, "5050" => "73999"
, "8888" => "1901335750"
, "30000" => "9992959"
, "43430" => "1901693331"
, "46664" => "1900399856"
, "55555" => "34407379"
, "102030" => "1900480466"
, "151515" => "57762957"
, "222222" => "2222222"
, "300000" => "9992959"
, "333333" => "33217"
, "414141" => "92817"
, "606060" => "91025"
, "909090" => "90944"
, "2602024" => "5602024"
, "3000000" => "9992959"
, "7777777" => "2222222"
, "8090100" => "38901"
, "14141414" => "43597665"
, "15000023" => "15002223"
, "15151515" => "57762957"
, "22222222" => "2222222"
, "200820082" => "1901783868"
, "222220022" => "2222222"
);
}
}
15 changes: 8 additions & 7 deletions library/IBAN/Rule/DE/Rule001001.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@

class Rule001001 extends \IBAN\Rule\DE\Rule000000
{
protected $instituteIdentificationSubstitutions = array(
"50050222" => "50050201"
);
protected function getInstituteIdentificationSubstitutions()
{
return array(
"50050222" => "50050201"
);
}

public function generateIban()
{
if ($this->instituteIdentificationEquals('50050201') &&
$this->bankAccountNumberEquals('2000')) {
if ($this->instituteIdentificationEquals('50050201') && $this->bankAccountNumberEquals('2000')) {
return 'DE42500502010000222000';
} elseif ($this->instituteIdentificationEquals('50050201') &&
$this->bankAccountNumberEquals('800000')) {
} elseif ($this->instituteIdentificationEquals('50050201') && $this->bankAccountNumberEquals('800000')) {
return 'DE89500502010000180802';
} else {
return parent::generateIban();
Expand Down
11 changes: 7 additions & 4 deletions library/IBAN/Rule/DE/Rule001100.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

class Rule001100 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"1000" => "8010001"
, "47800" => "47803"
);
protected function getBankAccountSubstitutions()
{
return array(
"1000" => "8010001"
, "47800" => "47803"
);
}
}
31 changes: 17 additions & 14 deletions library/IBAN/Rule/DE/Rule001501.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ public function __construct($localeCode, $instituteIdentification, $bankAccountN
parent::__construct($localeCode, '37060193', $bankAccountNumber);
}

protected $bankAccountSubstitutions = array(
"94" => "3008888018"
, "556" => "101010"
, "888" => "31870011"
, "4040" => "4003600101"
, "5826" => "1015826017"
, "25000" => "25000110"
, "393393" => "33013019"
, "444555" => "32230016"
, "603060" => "6002919018"
, "2120041" => "2130041"
, "80868086" => "4007375013"
, "400569017" => "4000569017"
);
protected function getBankAccountSubstitutions()
{
return array(
"94" => "3008888018"
, "556" => "101010"
, "888" => "31870011"
, "4040" => "4003600101"
, "5826" => "1015826017"
, "25000" => "25000110"
, "393393" => "33013019"
, "444555" => "32230016"
, "603060" => "6002919018"
, "2120041" => "2130041"
, "80868086" => "4007375013"
, "400569017" => "4000569017"
);
}
}
9 changes: 6 additions & 3 deletions library/IBAN/Rule/DE/Rule001600.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

class Rule001600 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"300000" => "18128012"
);
protected function getBankAccountSubstitutions()
{
return array(
"300000" => "18128012"
);
}
}
27 changes: 15 additions & 12 deletions library/IBAN/Rule/DE/Rule001700.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@

class Rule001700 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"100" => "2009090013"
, "111" => "2111111017"
, "240" => "2100240010"
, "4004" => "2204004016"
, "4444" => "2044444014"
, "6060" => "2016060014"
, "102030" => "1102030016"
, "333333" => "2033333016"
, "909090" => "2009090013"
, "50005000" => "5000500013"
);
protected function getBankAccountSubstitutions()
{
return array(
"100" => "2009090013"
, "111" => "2111111017"
, "240" => "2100240010"
, "4004" => "2204004016"
, "4444" => "2044444014"
, "6060" => "2016060014"
, "102030" => "1102030016"
, "333333" => "2033333016"
, "909090" => "2009090013"
, "50005000" => "5000500013"
);
}
}
17 changes: 10 additions & 7 deletions library/IBAN/Rule/DE/Rule001800.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

class Rule001800 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"556" => "120440110"
, "5435435430" => "543543543"
, "2157" => "121787016"
, "9800" => "120800019"
, "202050" => "1221864014"
);
protected function getBankAccountSubstitutions()
{
return array(
"556" => "120440110"
, "5435435430" => "543543543"
, "2157" => "121787016"
, "9800" => "120800019"
, "202050" => "1221864014"
);
}
}
9 changes: 6 additions & 3 deletions library/IBAN/Rule/DE/Rule002200.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

class Rule002200 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"1111111" => "2222200000"
);
protected function getBankAccountSubstitutions()
{
return array(
"1111111" => "2222200000"
);
}
}
9 changes: 6 additions & 3 deletions library/IBAN/Rule/DE/Rule002300.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

class Rule002300 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"700" => "1000700800"
);
protected function getBankAccountSubstitutions()
{
return array(
"700" => "1000700800"
);
}
}
15 changes: 9 additions & 6 deletions library/IBAN/Rule/DE/Rule002400.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

class Rule002400 extends \IBAN\Rule\DE\Rule000000
{
protected $bankAccountSubstitutions = array(
"94" => "1694"
, "248" => "17248"
, "345" => "17345"
, "400" => "14400"
);
protected function getBankAccountSubstitutions()
{
return array(
"94" => "1694"
, "248" => "17248"
, "345" => "17345"
, "400" => "14400"
);
}
}
Loading

0 comments on commit a2423cb

Please sign in to comment.