blib/lib/Net/UCP/TransactionManager.pm

filter: Statementstmt 39.0% 16 / 41 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 7 totaltotal 27.7% 20 / 72 CC 7 SCAR 17.9
CC
7
Cov
30%
get_trn
12.0
set_trn
12.0
next_trn
6.0
CRAP 6.0
↑ Summary
1 package Net::UCP::TransactionManager;
2  
3 1 ▶use 5.008007;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8  
9 1 our @ISA = qw(Exporter);
10 1 our @EXPORT = qw();
11  
12 1 our $VERSION = '0.02';
13  
14 1 ▶use constant HIGHEST_NBR => 99;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub new { bless({}, shift())->_init(@_); }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 0 ▶sub get_trn {
Subroutine get_trn: not called CC=3 SCAR=24.8
Pod undocumented
19 0 my ($self, $resp) = @_;
20
21 0 ▶ return unless defined $resp;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $resp 0 0 0
22 0 ▶ return $1 if ($resp =~ m/^(\d{2}).*/);
Branch: 1 branch
BranchTrueFalseTotal
if $resp =~ /^(\d{2}).*/ 0 0 0
23 }
24  
25 0 ▶sub next_trn {
Subroutine next_trn: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my $self = shift;
27
28 0 $self->{TRN}++;
29 0 ▶ ($self->{TRN} > HIGHEST_NBR) && do{ $self->{TRN} = 0 };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"TRN"} > 99 and do { $self->{"TRN"} = 0 } 0 0 0
30 0 return $self->{TRN};
31 }
32  
33 0 ▶sub current_trn {
Subroutine current_trn: not called CC=2 SCAR=17.9
Pod undocumented
34 0 my $self = shift;
35  
36 0 ▶ $self->reset_trn() if !defined $self->{TRN};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"TRN"} 0 0 0
37 0 return $self->{TRN};
38 }
39  
40 0 ▶sub set_trn {
Subroutine set_trn: not called CC=3 SCAR=24.8
Pod undocumented
41 0 my $self = shift;
42 0 my $tmp_trn = shift;
43  
44 0 ▶ if ($tmp_trn =~ m/\A\d+\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp_trn =~ /\A\d+\Z/) 0 0 0
45 0 $self->{TRN} = $tmp_trn;
46 0 ▶ $self->{TRN} = 0 if ($self->{TRN} > HIGHEST_NBR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"TRN"} > 99 0 0 0
47 }
48  
49 0 return $self->current_trn();
50 }
51  
52 0 ▶sub reset_trn {
Subroutine reset_trn: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $self = shift;
54 0 $self->{TRN} = 0;
55 }
56  
57 0 ▶sub padding {
Subroutine padding: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my $self = shift;
59 0 return sprintf("%02d", $self->{TRN});
60 }
61  
62 0 ▶sub _init {
Subroutine _init: not called CC=1 SCAR=6.9
63 0 my $self = shift;
64
65 0 $self->reset_trn();
66 0 $self;
67 }
68  
69 1 1;
70 __END__
↑ Summary