blib/lib/SWIFT/Factory/Tag/Tag21.pm

filter: Statementstmt 44.4% 16 / 36 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 41.6% 5 / 12 Podpod 100% 5 / 5 totaltotal 36.1% 26 / 72 CC 9 SCAR 23.5
CC
9
Cov
30%
reference
20.0
_store_reference
20.0
_init
12.0
CRAP 10.4
↑ Summary
1 package SWIFT::Factory::Tag::Tag21;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 ###########################################################################################################
6 # Provide a SWIFT TAG 21.
7 #
8 # Use this class to provide a Related Reference.
9 #
10 ###########################################################################################################
11  
12 1 ▶BEGIN{
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 *provide=*string;
14 1 *borken=*invalid;
15 }
16  
17 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 $VERSION='0.01';
19  
20 1 ▶use constant REF_MAX_LEN=>16;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 ###########################################################################################################
23 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
24 0 my$self={};
25 0 bless($self,shift())->_init(@_);
26 }
27  
28 ###########################################################################################################
29 # The class cannot guarantee that the TAG will be valid in the SWIFT network.
30 # It can point out that it's found some invalid data, though.
31 # Return number of problems detected.
32 0 ▶sub invalid {
Subroutine invalid: not called CC=1 SCAR=6.9
Pod documented
33 0 my$self=shift;
34  
35 # Implement verifications here!
36 0 0;
37 }
38  
39 ###########################################################################################################
40 0 ▶sub ref_max_len {
Subroutine ref_max_len: not called CC=1 SCAR=6.9
Pod documented
41 0 REF_MAX_LEN;
42 }
43  
44 ###########################################################################################################
45 # If a new Reference is provided, store it for future use.
46 # If requested, return the stored Reference to the caller.
47 0 ▶sub reference {
Subroutine reference: not called CC=4 SCAR=30.0
Pod documented
48 0 my($self,$reference)=@_;
49 0 ▶ defined($reference)&&$self->_store_reference($reference);
Branch: 1 branch
BranchTrueFalseTotal
defined $reference and $self->_store_reference($reference) 0 0 0
50 0 ▶ return(defined(wantarray)?wantarray?($self->{REFERENCE}):$self->{REFERENCE}:undef);
Branch: 2 branches
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
wantarray ? : 0 0 0
51 }
52  
53 ###########################################################################################################
54 0 ▶sub string {
Subroutine string: not called CC=1 SCAR=6.9
Pod documented
55 0 my$self=shift;
56 ':21:'.
57 $self->{REFERENCE}.
58 0 chr(13). # CR
59 chr(10); # LF
60 }
61  
62 ###########################################################################################################
63 ###########################################################################################################
64 #
65 # 'Internal' subs. Don't call these since they may, and will, change without notice.
66 #
67 ###########################################################################################################
68 ###########################################################################################################
69  
70 ###########################################################################################################
71 0 ▶sub _init {
Subroutine _init: not called CC=3 SCAR=24.8
72 0 my$self=shift();
73 0 my%args=(
74 DO_CLEANUP=>0,
75 REFERENCE=>'',
76 @_);
77  
78 0 ▶ $self->{DO_CLEANUP}=defined($args{DO_CLEANUP})?$args{DO_CLEANUP}?1:0:0;
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'DO_CLEANUP'} ? : 0 0 0
$args{'DO_CLEANUP'} ? : 0 0 0
79 0 $self->_store_reference($args{REFERENCE});
80 0 $self;
81 }
82  
83 ###########################################################################################################
84 # If Reference is defined, store it together with some simple cleanup applied.
85 0 ▶sub _store_reference {
Subroutine _store_reference: not called CC=4 SCAR=30.0
86 0 my($self,$reference)=@_;
87  
88 0 ▶ defined($reference)||return;
Branch: 1 branch
BranchTrueFalseTotal
defined $reference or return 0 0 0
89  
90 0 ▶ $self->{DO_CLEANUP}&&length($reference)>REF_MAX_LEN&&do{
Branch: 1 branch
BranchTrueFalseTotal
$self->{"DO_CLEANUP"} and length $reference > 16 and do { $reference = substr($reference, 0, 16) } 0 0 0
Condition0%0/3
$self->{"DO_CLEANUP"} and length $reference > 16
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"DO_CLEANUP"} and length $reference > 16
$self->{"DO_CLEANUP"} length $reference > 16
Truth table0%0/3
A and B
A= $self->{"DO_CLEANUP"}B= length $reference > 16
ABresult
0X0
100
111
91 # Apply conditional warnings here!
92 0 $reference=substr($reference,0,REF_MAX_LEN);
93 };
94  
95 0 $self->{REFERENCE}=$reference;
96 }
97  
98 ###########################################################################################################
99 1 'Choppers rule';
100 __END__
↑ Summary