DRI/Data/Changes.pm

filter: Statementstmt 91.8% 45 / 49 Branchbran 82.1% 23 / 28 Conditioncond 57.1% 12 / 21 MC/DCmcdc 18.1% 2 / 11 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 10 totaltotal 71.2% 94 / 132 CC 22 SCAR 16.2
CC
22
Cov
82%
types
7.1
new
7.0
is_empty
6.0
CRAP 5.0
« DRI/Protocol/Whois/Domain/TRAVEL.pm ↑ Summary DRI/Protocol/Whois/Domain/AERO.pm »
1 ## Domain Registry Interface, Handle bundle of changes
2 ##
3 ## Copyright (c) 2005,2008,2011,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 #########################################################################################
14  
15 package Net::DRI::Data::Changes;
16  
17 82 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 82 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 =pod
21  
22 =head1 NAME
23  
24 Net::DRI::Data::Changes - Bundle of changes in Net::DRI
25  
26 =head1 DESCRIPTION
27  
28 Please see the README file for details.
29  
30 =head1 SUPPORT
31  
32 For now, support questions should be sent to:
33  
34 E<lt>netdri@dotandco.comE<gt>
35  
36 Please also see the SUPPORT file in the distribution.
37  
38 =head1 SEE ALSO
39  
40 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
41  
42 =head1 AUTHOR
43  
44 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
45  
46 =head1 COPYRIGHT
47  
48 Copyright (c) 2005,2008,2011,2013 Patrick Mevzek <netdri@dotandco.com>.
49 All rights reserved.
50  
51 This program is free software; you can redistribute it and/or modify
52 it under the terms of the GNU General Public License as published by
53 the Free Software Foundation; either version 2 of the License, or
54 (at your option) any later version.
55  
56 See the LICENSE file that comes with this distribution for more details.
57  
58 =cut
59  
60 ##############################################################################################################################
61  
62 sub new
63 {
64 7 ▶ my ($class,$type,$op,$el)=@_;
Subroutine new: called CC=7 SCAR=19.5
Pod undocumented
65  
66 7 my $self={}; ## { 'type' => [ toadd, todel, toset ] } type=host,ip,status,contact,etc...
67 7 bless($self,$class);
68  
69 7 ▶ if (defined($type) && defined($op) && defined($el))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type and defined $op and defined $el) 6 1 7
Condition66%4/6
defined $type and defined $op and defined $el
!ll&&!rl&&r
106
defined $type and defined $op
!ll&&!rl&&r
106
MC/DC33%1/3
defined $type and defined $op and defined $el
defined $type defined $op defined $el
Truth table50%2/4
A and B and C
A= defined $typeB= defined $opC= defined $el
ABCresult
0XX0
10X0
1100
1111
70 {
71 6 $self->{$type}=[];
72 6 ▶ $self->{$type}->[0]=$el if ($op=~m/^(?:0|add)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /^(?:0|add)$/ 3 3 6
73 6 ▶ $self->{$type}->[1]=$el if ($op=~m/^(?:1|del)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /^(?:1|del)$/ 2 4 6
74 6 ▶ $self->{$type}->[2]=$el if ($op=~m/^(?:2|set)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /^(?:2|set)$/ 1 5 6
75 }
76  
77 7 return $self;
78 }
79  
80 1 ▶sub new_add { return shift->new(shift,'add',shift); }
Subroutine new_add: called CC=1 SCAR=0.0
Pod undocumented
81 1 ▶sub new_del { return shift->new(shift,'del',shift); }
Subroutine new_del: called CC=1 SCAR=0.0
Pod undocumented
82 1 ▶sub new_set { return shift->new(shift,'set',shift); }
Subroutine new_set: called CC=1 SCAR=0.0
Pod undocumented
83  
84 sub types
85 {
86 19 ▶ my ($self,$type)=@_;
Subroutine types: called CC=7 SCAR=19.6
Pod undocumented
87 19 ▶ if (! defined $type)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type) 9 10 19
88 {
89 9 my @r=sort { $a cmp $b } keys %$self;
90 9 return @r;
91 }
92 10 my @r;
93 10 ▶ return @r unless (exists($self->{$type}) && defined($self->{$type}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$type} and defined $self->{$type} 0 10 10
Condition33%1/3
exists $self->{$type} and defined $self->{$type}
!ll&&!rl&&r
0010
MC/DC0%0/2
exists $self->{$type} and defined $self->{$type}
exists $self->{$type} defined $self->{$type}
Truth table33%1/3
A and B
A= exists $self->{$type}B= defined $self->{$type}
ABresult
0X0
100
111
94 10 ▶ push @r,'add' if (defined($self->{$type}->[0]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{$type}[0] 5 5 10
95 10 ▶ push @r,'del' if (defined($self->{$type}->[1]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{$type}[1] 4 6 10
96 10 ▶ push @r,'set' if (defined($self->{$type}->[2]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{$type}[2] 2 8 10
97 10 return @r;
98 }
99  
100 sub _el
101 {
102 13 ▶ my ($self,$pos,$type,$new)=@_;
Subroutine _el: called CC=5 SCAR=16.4
103 13 ▶ unless (defined($new))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $new) 9 4 13
104 {
105 9 ▶ return unless (exists($self->{$type}) && defined($self->{$type}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$type} and defined $self->{$type} 0 9 9
Condition33%1/3
exists $self->{$type} and defined $self->{$type}
!ll&&!rl&&r
009
MC/DC0%0/2
exists $self->{$type} and defined $self->{$type}
exists $self->{$type} defined $self->{$type}
Truth table33%1/3
A and B
A= exists $self->{$type}B= defined $self->{$type}
ABresult
0X0
100
111
106 9 return $self->{$type}->[$pos];
107 }
108 4 ▶ $self->{$type}=[] unless (exists($self->{$type}));
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$type} 3 1 4
109 4 $self->{$type}->[$pos]=$new;
110  
111 4 return $self;
112 }
113  
114 5 ▶sub add { return shift->_el(0,shift,shift); }
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
115 5 ▶sub del { return shift->_el(1,shift,shift); }
Subroutine del: called CC=1 SCAR=0.0
Pod undocumented
116 3 ▶sub set { return shift->_el(2,shift,shift); }
Subroutine set: called CC=1 SCAR=0.0
Pod undocumented
117  
118 sub all_defined
119 {
120 5 ▶ my ($self,$type)=@_;
Subroutine all_defined: called CC=5 SCAR=16.8
Pod undocumented
121 5 ▶ return () unless (defined($type) && $type && exists($self->{$type}) && defined($self->{$type}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and $type and exists $self->{$type} and defined $self->{$type} 0 4 4
Condition66%6/9
defined $type and $type and exists $self->{$type} and defined $self->{$type}
!ll&&!rl&&r
104
defined $type and $type and exists $self->{$type}
!ll&&!rl&&r
104
defined $type and $type
!ll&&!rl&&r
104
MC/DC25%1/4
defined $type and $type and exists $self->{$type} and defined $self->{$type}
defined $type $type exists $self->{$type} defined $self->{$type}
Truth table40%2/5
A and B and C and D
A= defined $typeB= $typeC= exists $self->{$type}D= defined $self->{$type}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
122 4 return (grep { defined } @{$self->{$type}});
123 }
124  
125 sub is_empty
126 {
127 0 ▶ my $self=shift;
Subroutine is_empty: not called CC=2 SCAR=17.9
Pod undocumented
128 0 my @o=map { $self->all_defined($_) } $self->types();
129 0 ▶ return @o? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
@o ? : 0 0 0
130 }
131  
132 ##############################################################################################################################
133 82 1;
« DRI/Protocol/Whois/Domain/TRAVEL.pm ↑ Summary DRI/Protocol/Whois/Domain/AERO.pm »