Workflow/Persister/DBI/AutoGeneratedId.pm

filter: Statementstmt 92.6% 38 / 41 Branchbran 75.0% 12 / 16 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 88.6% 70 / 79 CC 12 SCAR 15.9
CC
12
Cov
87%
new
7.9
post_fetch_id
6.0
BEGIN
1.0
CRAP 4.9
« Workflow/Factory.pm ↑ Summary Workflow/Persister/DBI.pm »
1 package Workflow::Persister::DBI::AutoGeneratedId;
2  
3 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use parent qw( Class::Accessor );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use Workflow::Exception qw( configuration_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 19 $Workflow::Persister::DBI::AutoGeneratedId::VERSION = '2.12';
11  
12 19 my @FIELDS = qw( log from_handle handle_property func_property );
13 19 __PACKAGE__->mk_accessors(@FIELDS);
14  
15 3 ▶sub new {
Subroutine new: called CC=7 SCAR=20.6
Pod documented
16 3 my ( $class, $params ) = @_;
17  
18 3 my $self =
19 bless { log => Log::Any->get_logger( category => $class ) }, $class;
20 3 for (@FIELDS) {
21 12 ▶ $self->$_( $params->{$_} ) if ( $params->{$_} );
Branch: 1 branch
BranchTrueFalseTotal
if $params->{$_} 5 7 12
22 }
23 3 ▶ if ( my $handle_type = $self->from_handle ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $handle_type = $self->from_handle) { } 2 1 3
elsif (not $self->func_property) { } 0 1 1
24 2 ▶ unless ( $handle_type =~ /^(database|statement)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($handle_type =~ /^(database|statement)$/u) 0 2 2
25 0 configuration_error "Parameter 'from_handle' must be 'database' ",
26 "or 'statement' (Given: '$handle_type')";
27 }
28 2 ▶ unless ( $self->handle_property ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->handle_property) 0 2 2
29 0 configuration_error "If you specify 'from_handle' you must ",
30 "specify a value for 'handle_property'";
31 }
32 2 $self->log->debug( "Using '", $self->handle_property, "' from ", "'",
33 $self->from_handle, "' for ID generator" );
34 } elsif ( !$self->func_property ) {
35 0 configuration_error "If you do not specify a value in 'from_handle' ",
36 "you must specify a value for 'func_property'";
37 } else {
38 1 $self->log->debug( "Using database func() property '",
39 $self->func_property, "' for ID generator" );
40 }
41 3 return $self;
42 }
43  
44 3 ▶sub pre_fetch_id {return}
Subroutine pre_fetch_id: called CC=1 SCAR=0.0
Pod documented
45  
46 3 ▶sub post_fetch_id {
Subroutine post_fetch_id: called CC=6 SCAR=18.0
Pod documented
47 3 my ( $self, $dbh, $sth ) = @_;
48  
49 3 my $from_handle = $self->from_handle;
50  
51 3 ▶ if ( defined $from_handle and $from_handle eq 'database' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $from_handle and $from_handle eq 'database') { } 1 2 3
elsif (defined $from_handle and $from_handle eq 'statement') { } 1 1 2
elsif (my $func_property = $self->func_property) { } 1 0 1
Condition100%3/3
defined $from_handle and $from_handle eq "database"
!ll&&!rl&&r
111
MC/DC100%2/2
defined $from_handle and $from_handle eq "database"
defined $from_handle $from_handle eq "database"
Truth table100%3/3
A and B
A= defined $from_handleB= $from_handle eq "database"
ABresult
0X0
100
111
52 1 return $dbh->{ $self->handle_property };
53 ▶ } elsif ( defined $from_handle and $from_handle eq 'statement' ) {
Condition66%2/3
defined $from_handle and $from_handle eq "statement"
!ll&&!rl&&r
101
MC/DC50%1/2
defined $from_handle and $from_handle eq "statement"
defined $from_handle $from_handle eq "statement"
Truth table66%2/3
A and B
A= defined $from_handleB= $from_handle eq "statement"
ABresult
0X0
100
111
54 1 return $sth->{ $self->handle_property };
55 } elsif ( my $func_property = $self->func_property ) {
56 1 return $dbh->func($func_property);
57 }
58 }
59  
60 19 1;
61  
62 __END__
« Workflow/Factory.pm ↑ Summary Workflow/Persister/DBI.pm »