| 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
| |||||||||||
| 22 | 0 | ▶ | return $1 if ($resp =~ m/^(\d{2}).*/); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 45 | 0 | $self->{TRN} = $tmp_trn; | |||||||||
| 46 | 0 | ▶ | $self->{TRN} = 0 if ($self->{TRN} > HIGHEST_NBR); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||