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