File Coverage

blib/lib/Business/BancaSella/Decode.pm
Criterion Covered Total %
statement 41 43 95.3
branch 5 8 62.5
condition 2 6 33.3
subroutine 10 11 90.9
pod 1 4 25.0
total 59 72 81.9


line stmt bran cond sub pod time code
1             package Business::BancaSella::Decode;
2              
3             $VERSION = "0.11";
4 0     0 0 0 sub Version { $VERSION; }
5              
6             require 5.004;
7 1     1   5353 use Carp;
  1         2  
  1         216  
8 1     1   8 use strict;
  1         2  
  1         41  
9 1     1   7 use warnings;
  1         25  
  1         39  
10              
11 1     1   1067 use Business::BancaSella::Decode::Gestpay;
  1         15  
  1         41  
12 1     1   951 use Business::BancaSella::Decode::Gateway;
  1         2  
  1         420  
13              
14             my %fields =
15             (
16             type => 'gestpay',
17             );
18            
19             my @fields_req = qw/type/;
20            
21             sub new
22             {
23 2     2 1 281 my $proto = shift;
24 2   33     16 my $class = ref($proto) || $proto;
25 2         7 my $self = {};
26 2         6 bless $self,$class;
27 2         14 $self->init(@_);
28 2         11 return $self;
29             }
30              
31             sub init {
32 2     2 0 5 my $self = shift;
33 2         11 my (%options) = @_;
34             # Assign default options
35 2         16 while (my ($key,$value) = each(%fields)) {
36 2   33     25 $self->{$key} = $self->{$key} || $value;
37             }
38             # Assign options
39 2         9 while (my ($key,$value) = each(%options)) {
40 4         14 $self->{$key} = $value
41             }
42             # Check required params
43 2         8 foreach (@fields_req) {
44 2 50       10 croak "You must declare '$_' in " . ref($self) . "::new"
45             if (!defined $self->{$_});
46             }
47 2 100       10 if ($self->type eq 'gestpay') {
    50          
48 1     1   6 no strict 'vars';
  1         1  
  1         50  
49 1         17 unshift @ISA,'Business::BancaSella::Decode::Gestpay';
50             } elsif ($self->type eq 'gateway') {
51 1     1   4 no strict 'vars';
  1         2  
  1         143  
52 1         37 unshift @ISA,'Business::BancaSella::Decode::Gateway';
53             } else {
54 0         0 croak "Unsupported type " . $self->type . "in " . ref($self) . "::new";
55             }
56 2         30 $self->SUPER::init(@_);
57             }
58              
59 3 50   3 0 6 sub type { my $s=shift; return @_ ? ($s->{type}=shift) : $s->{type} }
  3         20  
60              
61             # Preloaded methods go here.
62              
63             1;
64             __END__