lib/Finance/Bank/Wachovia/Account.pm

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