NAB/FileContainer.pm

filter: Statementstmt 100% 40 / 40 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 94.8% 55 / 58 CC 6 SCAR 11.5
CC
6
Cov
96%
new_from_file
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« NAB/Australian/DirectEntry/Payments/DetailRecord.pm ↑ Summary NAB/BPAY/Payments/Results.pm »
1 package Business::NAB::FileContainer;
2 8 $Business::NAB::FileContainer::VERSION = '0.11';
3 # undocument abstract class
4  
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use feature qw/ signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use autodie qw/ :all /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶no warnings qw/ experimental::signatures /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 ▶use Business::NAB::Types qw/ decamelize /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 7 ▶sub new_from_file (
Subroutine new_from_file: called CC=6 SCAR=18.0
Pod undocumented
17 $self,
18 $parent,
19 $file,
20 $sub_class_map,
21 7 $split_char = undef,
22 ) {
23 7 open( my $fh, '<', $file );
24  
25 7 ▶ while ( my $line = <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 70 7 77
26  
27 70 $line =~ s/\r\n$//;
28  
29 70 ▶ my ( $type ) = $split_char
Branch: 1 branch
BranchTrueFalseTotal
$split_char ? : 10 60 70
30 ? ( split( $split_char, $line ) )[ 0 ]
31 : substr( $line, 0, 1 );
32  
33 70 ▶ next if !length( $type );
Branch: 1 branch
BranchTrueFalseTotal
unless length $type 0 70 70
34  
35 70 my $sub_class = $sub_class_map->{ $type };
36 70 my $attr = decamelize( $sub_class );
37 70 my $push = "add_${attr}";
38  
39 70 ▶ $sub_class || croak( "Unrecognised record type ($type) at line $." );
Branch: 1 branch
BranchTrueFalseTotal
$sub_class or croak("Unrecognised record type ($type) at line $.") 70 0 70
40 70 $sub_class = "${parent}::${sub_class}";
41  
42 70 my $Instance = $sub_class->new_from_record( $line );
43  
44 70 $self->$push( $Instance );
45 }
46  
47 7 return $self;
48 }
49  
50 8 1;
« NAB/Australian/DirectEntry/Payments/DetailRecord.pm ↑ Summary NAB/BPAY/Payments/Results.pm »