lib/Finance/Bank/Wachovia/Account.pm

filter: Statementstmt 85.7% 84 / 98 Branchbran 59.3% 19 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 21 / 24 Podpod 70.0% 7 / 10 totaltotal 79.8% 131 / 164 SCAR 32.7
CC
22
Cov
79%
posted_balance
12.0
set_transactions
4.0
get_transactions
4.0
CRAP 26.3
« lib/Finance/Bank/Wachovia/DataObtainer/WWW.pm ↑ Summary lib/Finance/Bank/Wachovia.pm »
1 package Finance::Bank::Wachovia::Account;
2 3 ▶use Finance::Bank::Wachovia::ErrorHandler;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.3';
7 3 my @attrs;
8 3 our @ISA = qw/Finance::Bank::Wachovia::ErrorHandler/;
9  
10 BEGIN{
11 3 ▶ @attrs = qw(
Subroutine BEGIN: called CC=2 SCAR=6.9
12 name
13 number
14 type
15 available_balance
16 posted_balance
17 transactions
18 data_obtainer
19 );
20
21 3 my $x = @__SUPER__::ATTRIBUTES;
22 3 for( @attrs ){
23 21 ▶ eval "sub _$_ { $x }";
Subroutine _available_balance: called CC=1 SCAR=0.0
Subroutine _data_obtainer: called CC=1 SCAR=0.0
Subroutine _name: called CC=1 SCAR=0.0
Subroutine _number: called CC=1 SCAR=0.0
Subroutine _posted_balance: not called CC=1 SCAR=0.0
Subroutine _transactions: called CC=1 SCAR=0.0
Subroutine _type: called CC=1 SCAR=0.0
24 21 $x++;
25 }
26 }
27  
28 sub new {
29 4 ▶ my($class, %attrs) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
30 4 my $self = [];
31 4 bless $self, $class;
32 4 foreach my $att ( keys %attrs ){
33 8 $self->$att( $attrs{$att} );
34 }
35 4 ▶ return Finance::Bank::Wachovia::Account->Error("no account number set in Finance::Bank::Wachovia::Account->new")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->number 0 4 4
36 unless $self->number;
37 4 return $self;
38 }
39  
40 sub AUTOLOAD {
41 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 25 ▶ our $AUTOLOAD;
Subroutine AUTOLOAD: called CC=3 SCAR=11.0
43 25 my $self = shift;
44 25 my $attr = lc $AUTOLOAD;
45 25 $attr =~ s/.*:://;
46 25 ▶ return $self->Error( "$attr not a valid attribute" )
Branch: 1 branch
BranchTrueFalseTotal
unless grep /$attr/, @attrs 0 25 25
47 unless grep /$attr/, @attrs;
48 # get if no args passed
49 25 ▶ return $self->[ &{"_$attr"} ] unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 17 8 25
50 # set if args passed
51 8 $self->[ &{"_$attr"} ] = shift;
52 8 return $self;
53 }
54  
55 sub add_transaction {
56 147 ▶ my($self) = shift;
Subroutine add_transaction: called CC=3 SCAR=11.0
Pod undocumented
57 147 foreach my $t ( @_ ){
58 147 ▶ return $self->Error( "Must pass valid Transaction object" )
Branch: 1 branch
BranchTrueFalseTotal
unless $t->isa("Finance::Bank::Wachovia::Transaction") 0 147 147
59 unless $t->isa('Finance::Bank::Wachovia::Transaction');
60 147 push @{ $self->[ _transactions ] }, $t;
61 }
62 147 return $self;
63 }
64  
65 sub set_transactions {
66 2 ▶ my($self, $transactions) = @_;
Subroutine set_transactions: called CC=4 SCAR=13.9
Pod undocumented
67 2 ▶ unless ( ref $transactions eq 'ARRAY' ){
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $transactions eq "ARRAY") 1 1 2
68 1 $self->[ _transactions ] = [];
69 1 return $self;
70 }
71 1 foreach my $t ( @$transactions ){
72 3 ▶ return $self->Error( "Must pass valid Transaction objects" )
Branch: 1 branch
BranchTrueFalseTotal
unless $t->isa("Finance::Bank::Wachovia::Transaction") 0 3 3
73 unless $t->isa('Finance::Bank::Wachovia::Transaction');
74 }
75 1 $self->[ _transactions ] = $transactions;
76 1 return $self;
77 }
78  
79 1 ▶sub balance { available_balance(@_) }
Subroutine balance: called CC=1 SCAR=0.0
Pod documented
80 1 ▶sub transactions { get_transactions(@_) }
Subroutine transactions: called CC=1 SCAR=0.0
Pod documented
81  
82  
83 # these values are loaded on-demand
84 sub posted_balance {
85 0 ▶ my $self = shift;
Subroutine posted_balance: not called CC=3 SCAR=24.8
Pod documented
86 0 ▶ if(@_){ $self->[ _posted_balance ] = shift; return $self; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
87 0 ▶ return $self->[ _posted_balance ] if $self->[ _posted_balance ];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[_posted_balance()] 0 0 0
88 0 my $do = $self->data_obtainer();
89 0 my $posted_bal = $do->get_account_posted_balance( $self->number() );
90 0 $self->[ _posted_balance ] = $posted_bal;
91 0 return $posted_bal;
92 }
93  
94 sub get_transactions {
95 6 ▶ my $self = shift;
Subroutine get_transactions: called CC=4 SCAR=13.9
Pod documented
96 6 ▶ return $self->[ _transactions ] if $self->[ _transactions ];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[_transactions()] 4 2 6
97
98 2 my $do = $self->data_obtainer();
99 2 my $transactions = $do->get_account_transactions( $self->number() );
100 2 foreach ( @$transactions ){
101 146 ▶ my $t = Finance::Bank::Wachovia::Transaction->new( %$_ )
Branch: 1 branch
BranchTrueFalseTotal
my $t = "Finance::Bank::Wachovia::Transaction"->new(%$_) or return $self->Error("Couldn't make transaction object") 0 146 146
102 or return $self->Error( "Couldn't make transaction object" );
103 146 $self->add_transaction( $t );
104 }
105 2 return $self->[ _transactions ];
106 }
107  
108 sub name {
109 2 ▶ my $self = shift;
Subroutine name: called CC=3 SCAR=12.3
Pod documented
110 2 ▶ if(@_){ $self->[ _name ] = shift; return $self; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
111 2 ▶ return $self->[ _name ] if $self->[ _name ];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[_name()] 0 2 2
112 2 $self->[ _name ] = $self->data_obtainer->get_account_name( $self->number );
113 2 return $self->[ _name ];
114 }
115  
116 sub type {
117 3 ▶ my $self = shift;
Subroutine type: called CC=3 SCAR=11.0
Pod documented
118 3 ▶ if(@_){ $self->[ _type ] = shift; return $self; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 2 3
119 2 ▶ return $self->[ _type ] if $self->[ _type ];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[_type()] 1 1 2
120 1 $self->[ _type ] = $self->data_obtainer->get_account_type( $self->number );
121 1 return $self->[ _type ];
122 }
123  
124 sub available_balance {
125 1 ▶ my $self = shift;
Subroutine available_balance: called CC=3 SCAR=12.3
Pod documented
126 1 ▶ if(@_){ $self->[ _available_balance ] = shift; return $self; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
127 1 ▶ return $self->[ _available_balance ] if $self->[ _available_balance ];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[_available_balance()] 0 1 1
128 1 $self->[ _available_balance ] = $self->data_obtainer->get_account_available_balance( $self->number );
129 1 return $self->[ _available_balance ];
130 }
131  
132 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
133  
134 __END__
« lib/Finance/Bank/Wachovia/DataObtainer/WWW.pm ↑ Summary lib/Finance/Bank/Wachovia.pm »