FIX/Group.pm

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 95.7% 45 / 47 CC 6 SCAR 9.2
CC
6
Cov
95%
serialize
4.0
new
3.1
BEGIN
1.0
CRAP 2.5
« FIX.pm ↑ Summary FIX/TagsAccessor.pm »
1 package Protocol::FIX::Group;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use Protocol::FIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 18 our $VERSION = '0.08'; ## VERSION
9  
10 =head1 NAME
11  
12 Protocol::FIX::Group - allows repetition of common fieds/groups/components
13  
14 =cut
15  
16 =head1 METHODS (for protocol developers)
17  
18 =head3 new
19  
20 new($class, $name, $composites)
21  
22 Creates new Group (performed by Protocol, when it parses XML definition)
23  
24 =cut
25  
26 18 ▶use mro;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 18 ▶use parent qw/Protocol::FIX::BaseComposite/;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 651 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
30 651 my ($class, $base_field, $composites) = @_;
31  
32 651 ▶ die "base field for group must be a class of 'Protocol::FIX::Field'"
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($base_field, "Protocol::FIX::Field") 0 651 651
33 unless UNIVERSAL::isa($base_field, "Protocol::FIX::Field");
34  
35 die "type of base field must be strictly 'NUMINGROUP'"
36 651 ▶ unless $base_field->{type} eq 'NUMINGROUP';
Branch: 1 branch
BranchTrueFalseTotal
unless $base_field->{"type"} eq "NUMINGROUP" 0 651 651
37  
38 651 my $obj = next::method($class, $base_field->{name}, 'group', $composites);
39  
40 650 $obj->{base_field} = $base_field;
41  
42 650 return $obj;
43 }
44  
45 =head3 serialize
46  
47 serialize($self, $values)
48  
49 Serializes array of C<$values>. Not for end-user usage. Please, refer
50 L<Message/"serialize">
51  
52 =cut
53  
54 19 ▶sub serialize {
Subroutine serialize: called CC=4 SCAR=13.9
Pod documented
55 19 my ($self, $repetitions) = @_;
56  
57 19 ▶ die '$repetitions must be ARRAY in $obj->serialize($repetitions)'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $repetitions eq "ARRAY" 1 18 19
58 unless ref($repetitions) eq 'ARRAY';
59  
60 18 ▶ die '@repetitions must be non-empty in $obj->serialize($repetitions)'
Branch: 1 branch
BranchTrueFalseTotal
if @$repetitions == 0 1 17 18
61 if @$repetitions == 0;
62  
63 17 my @strings = ($self->{base_field}->serialize(scalar @$repetitions));
64  
65 17 for my $values (@$repetitions) {
66 24 push @strings, $self->next::method($values);
67 }
68  
69 13 return join $Protocol::FIX::SEPARATOR, @strings;
70 }
71  
72 18 1;
« FIX.pm ↑ Summary FIX/TagsAccessor.pm »