00001 <?php
00002
00007 class oxSepaValidator
00008 {
00009
00013 protected $_aIBANCodeLengths = array(
00014 'AL' => 28,
00015 'AD' => 24,
00016 'AT' => 20,
00017 'AZ' => 28,
00018 'BH' => 22,
00019 'BE' => 16,
00020 'BA' => 20,
00021 'BR' => 29,
00022 'BG' => 22,
00023 'CR' => 21,
00024 'HR' => 21,
00025 'CY' => 28,
00026 'CZ' => 24,
00027 'DK' => 18,
00028 'FO' => 18,
00029 'GL' => 18,
00030 'DO' => 28,
00031 'EE' => 20,
00032 'FI' => 18,
00033 'FR' => 27,
00034 'GE' => 22,
00035 'DE' => 22,
00036 'GI' => 23,
00037 'GR' => 27,
00038 'GT' => 28,
00039 'HU' => 28,
00040 'IS' => 26,
00041 'IE' => 22,
00042 'IL' => 23,
00043 'IT' => 27,
00044 'KZ' => 20,
00045 'KW' => 30,
00046 'LV' => 21,
00047 'LB' => 28,
00048 'LI' => 21,
00049 'LT' => 20,
00050 'LU' => 20,
00051 'MK' => 19,
00052 'MT' => 31,
00053 'MR' => 27,
00054 'MU' => 30,
00055 'MD' => 24,
00056 'MC' => 27,
00057 'ME' => 22,
00058 'NL' => 18,
00059 'NO' => 15,
00060 'PK' => 24,
00061 'PS' => 29,
00062 'PL' => 28,
00063 'PT' => 25,
00064 'RO' => 24,
00065 'SM' => 27,
00066 'SA' => 24,
00067 'RS' => 22,
00068 'SK' => 24,
00069 'SI' => 19,
00070 'ES' => 24,
00071 'SE' => 24,
00072 'CH' => 21,
00073 'TN' => 24,
00074 'TR' => 26,
00075 'AE' => 23,
00076 'GB' => 22,
00077 'VG' => 24
00078 );
00079
00087 public function isValidBIC($sBIC)
00088 {
00089 $oBICValidator = oxNew('oxSepaBICValidator');
00090
00091 return $oBICValidator->isValid($sBIC);
00092 }
00093
00101 public function isValidIBAN($sIBAN)
00102 {
00103 $oIBANValidator = oxNew('oxSepaIBANValidator');
00104 $oIBANValidator->setCodeLengths($this->getIBANCodeLengths());
00105
00106 return $oIBANValidator->isValid($sIBAN);
00107 }
00108
00118 public function isValidIBANRegistry($aIBANRegistry = null)
00119 {
00120 $oIBANValidator = oxNew('oxSepaIBANValidator');
00121
00122 if (is_null($aIBANRegistry)) {
00123 $aIBANRegistry = $this->getIBANCodeLengths();
00124 }
00125
00126 return $oIBANValidator->isCodeLengthsValid($aIBANRegistry);
00127 }
00128
00129
00139 public function setIBANRegistry($aIBANRegistry)
00140 {
00141 if ($this->isValidIBANRegistry($aIBANRegistry)) {
00142 $this->_aIBANCodeLengths = $aIBANRegistry;
00143
00144 return true;
00145 } else {
00146 return false;
00147 }
00148 }
00149
00157 public function getIBANRegistry()
00158 {
00159 return $this->_aIBANCodeLengths;
00160 }
00161
00167 public function getIBANCodeLengths()
00168 {
00169 return $this->_aIBANCodeLengths;
00170 }
00171 }