blib/lib/Business/IBAN/NL/BIC.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 8 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 42 CC 5 SCAR 21.6
CC
5
Cov
0%
bic
12.0
name
12.0
new
2.0
CRAP 8.7
1 package Business::IBAN::NL::BIC;
2  
3 use warnings;
4 use strict;
5  
6 our $VERSION = '1.00';
7  
8 my %bic;
9 my %name;
10  
11 foreach ( <DATA> ) {
12 my ( $bic, $bankcode, @name ) = split /\s+/;
13 $bic{$bankcode} = $bic;
14 $name{$bankcode} = join ( ' ', @name );
15 }
16 close DATA;
17  
18 sub new {
19 bless {}, shift;
20 }
21  
22 sub bic {
23 my $self = shift if ref $_[0];
24 my $iban = uc ( shift );
25
26 if ( $iban =~ /^NL[0-9]{2}([A-Z]{4})[0-9]+$/ ) {
27 return $bic{$1};
28 }
29 return undef;
30
31 }
32  
33 sub name {
34 my $self = shift if ref $_[0];
35 my $iban = uc ( shift );
36
37 if ( $iban =~ /^NL[0-9]{2}([A-Z]{4})[0-9]+$/ ) {
38 return $name{$1};
39 }
40 return undef;
41
42 }
43  
44 1;
45  
46 =head1 NAME
47  
48 Business::IBAN::NL::BIC - Lookup Dutch BIC and bank names from IBAN numbers.
49  
50 =head1 DESCRIPTION
51  
52 For Dutch IBAN numbers the bank code is contained within the account number.
53 The bank code can be used to determine the BIC and the name of the bank at
54 which the account is located.
55  
56 The information contained in this module is taken from
57 https://www.betaalvereniging.nl/giraal-en-online-betalen/sepa-documentatie-voor-nederland/bic-afleiden-uit-iban/
58 and contains correct information as of the date of the upload of this
59 module. Last changes on that page were made on 4th of March 2016.
60  
61 =head1 LIMITATIONS
62  
63 This module works only for valid Dutch IBAN numbers. It does not check IBAN
64 numbers for correctness, please take a look at Business::IBAN::Validator for
65 that.
66  
67 =head1 METHODS
68  
69 This module provides an object oriented interface but all methods can also
70 be called as regular functions (specify full package name in those cases,
71 function names are not exported).
72  
73 =head2 new
74  
75 Constructor; does not take any arguments.
76  
77 =head2 bic($iban)
78  
79 Return the BIC code for a specific Dutch IBAN. If the IBAN is not Dutch or
80 the bank code contained in the IBAN is not recognized this method returns
81 undef.
82  
83 =head2 name($iban)
84  
85 Return the name of the bank controlling the specified Dutch IBAN account. If
86 the IBAN is not Dutch or the bank code contained in the IBAN is not
87 recognized this method returns undef.
88  
89 =head1 LICENSE
90  
91 This program is free software; you can redistribute it and/or modify it
92 under the same terms as Perl itself.
93  
94 =cut
95  
96 __DATA__