oophp-iban.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. namespace PHP_IBAN;
  3. # OO wrapper for 'php-iban.php'
  4. Class IBAN {
  5. function __construct($iban = '') {
  6. require_once('php-iban.php'); # load the procedural codebase
  7. $this->iban = $iban;
  8. }
  9. public function Verify($iban='',$machine_format_only=false) {
  10. if($iban!='') { return verify_iban($iban,$machine_format_only); }
  11. return verify_iban($this->iban,$machine_format_only);
  12. # we could throw exceptions of various types, but why - does it really
  13. # add anything? possibly some slightly better user feedback potential.
  14. # however, this can be written by hand by performing individual checks
  15. # ala the code in verify_iban() itself where required, which is likely
  16. # almost never. for the increased complexity and
  17. # maintenance/documentation cost, i say, therefore: no. no exceptions.
  18. }
  19. public function VerifyMachineFormatOnly($iban='') {
  20. if($iban!='') { return verify_iban($iban,true); }
  21. return verify_iban($this->iban,true);
  22. }
  23. public function MistranscriptionSuggestions() {
  24. return iban_mistranscription_suggestions($this->iban);
  25. }
  26. public function MachineFormat() {
  27. return iban_to_machine_format($this->iban);
  28. }
  29. public function HumanFormat() {
  30. return iban_to_human_format($this->iban);
  31. }
  32. public function ObfuscatedFormat() {
  33. return iban_to_obfuscated_format($this->iban);
  34. }
  35. public function Country($iban='') {
  36. return iban_get_country_part($this->iban);
  37. }
  38. public function Checksum($iban='') {
  39. return iban_get_checksum_part($this->iban);
  40. }
  41. public function NationalChecksum($iban='') {
  42. return iban_get_nationalchecksum_part($this->iban);
  43. }
  44. public function BBAN() {
  45. return iban_get_bban_part($this->iban);
  46. }
  47. public function VerifyChecksum() {
  48. return iban_verify_checksum($this->iban);
  49. }
  50. public function FindChecksum() {
  51. return iban_find_checksum($this->iban);
  52. }
  53. public function SetChecksum() {
  54. $this->iban = iban_set_checksum($this->iban);
  55. }
  56. public function ChecksumStringReplace() {
  57. return iban_checksum_string_replace($this->iban);
  58. }
  59. public function FindNationalChecksum() {
  60. return iban_find_nationalchecksum($this->iban);
  61. }
  62. public function SetNationalChecksum() {
  63. $this->iban = iban_set_nationalchecksum($this->iban);
  64. }
  65. public function VerifyNationalChecksum() {
  66. return iban_verify_nationalchecksum($this->iban);
  67. }
  68. public function Parts() {
  69. return iban_get_parts($this->iban);
  70. }
  71. public function Bank() {
  72. return iban_get_bank_part($this->iban);
  73. }
  74. public function Branch() {
  75. return iban_get_branch_part($this->iban);
  76. }
  77. public function Account() {
  78. return iban_get_account_part($this->iban);
  79. }
  80. public function Countries() {
  81. return iban_countries();
  82. }
  83. }
  84. # IBANCountry
  85. Class IBANCountry {
  86. # constructor with code
  87. function __construct($code = '') {
  88. $this->code = $code;
  89. }
  90. public function Code() {
  91. return $this->code;
  92. }
  93. public function Name() {
  94. return iban_country_get_country_name($this->code);
  95. }
  96. public function DomesticExample() {
  97. return iban_country_get_domestic_example($this->code);
  98. }
  99. public function BBANExample() {
  100. return iban_country_get_bban_example($this->code);
  101. }
  102. public function BBANFormatSWIFT() {
  103. return iban_country_get_bban_format_swift($this->code);
  104. }
  105. public function BBANFormatRegex() {
  106. return iban_country_get_bban_format_regex($this->code);
  107. }
  108. public function BBANLength() {
  109. return iban_country_get_bban_length($this->code);
  110. }
  111. public function IBANExample() {
  112. return iban_country_get_iban_example($this->code);
  113. }
  114. public function IBANFormatSWIFT() {
  115. return iban_country_get_iban_format_swift($this->code);
  116. }
  117. public function IBANFormatRegex() {
  118. return iban_country_get_iban_format_regex($this->code);
  119. }
  120. public function IBANLength() {
  121. return iban_country_get_iban_length($this->code);
  122. }
  123. public function BankIDStartOffset() {
  124. return iban_country_get_bankid_start_offset($this->code);
  125. }
  126. public function BankIDStopOffset() {
  127. return iban_country_get_bankid_stop_offset($this->code);
  128. }
  129. public function BranchIDStartOffset() {
  130. return iban_country_get_branchid_start_offset($this->code);
  131. }
  132. public function BranchIDStopOffset() {
  133. return iban_country_get_branchid_stop_offset($this->code);
  134. }
  135. public function NationalChecksumStartOffset() {
  136. return iban_country_get_nationalchecksum_start_offset($this->code);
  137. }
  138. public function NationalChecksumStopOffset() {
  139. return iban_country_get_nationalchecksum_stop_offset($this->code);
  140. }
  141. public function RegistryEdition() {
  142. return iban_country_get_registry_edition($this->code);
  143. }
  144. public function SWIFTOfficial() {
  145. return iban_country_get_country_swift_official($this->code);
  146. }
  147. public function IsSEPA() {
  148. return iban_country_is_sepa($this->code);
  149. }
  150. public function IANA() {
  151. return iban_country_get_iana($this->code);
  152. }
  153. public function ISO3166() {
  154. return iban_country_get_iso3166($this->code);
  155. }
  156. public function ParentRegistrar() {
  157. return iban_country_get_parent_registrar($this->code);
  158. }
  159. public function CurrencyISO4217() {
  160. return iban_country_get_currency_iso4217($this->code);
  161. }
  162. public function CentralBankURL() {
  163. return iban_country_get_central_bank_url($this->code);
  164. }
  165. public function CentralBankName() {
  166. return iban_country_get_central_bank_name($this->code);
  167. }
  168. public function Membership() {
  169. return iban_country_get_membership($this->code);
  170. }
  171. public function IsEuMember() {
  172. return iban_country_get_is_eu_member($this->code);
  173. }
  174. }
  175. ?>