DRI/Data/Contact/BE.pm

filter: Statementstmt 33.3% 14 / 42 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 35 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 57.1% 4 / 7 Podpod 33.3% 1 / 3 totaltotal 13.9% 19 / 136 CC 27 SCAR 54.3
CC
27
Cov
13%
validate
380.0
init
42.0
type
20.0
CRAP 229.0
« DRI/Protocol/EPP/Extensions/NO/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/CAT/DefensiveRegistration.pm »
1 ## Domain Registry Interface, Handling of contact data for .BE
2 ##
3 ## Copyright (c) 2006,2008,2009,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::Contact::BE;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use base qw/Net::DRI::Data::Contact/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 __PACKAGE__->register_attributes(qw(vat lang));
25  
26 =pod
27  
28 =head1 NAME
29  
30 Net::DRI::Data::Contact::BE - Handle .BE contact data for Net::DRI
31  
32 =head1 DESCRIPTION
33  
34 This subclass of Net::DRI::Data::Contact adds accessors and validation for
35 .BE specific data.
36  
37 =head1 METHODS
38  
39 The following accessors/mutators can be called in chain, as they all return the object itself.
40  
41 =head2 type()
42  
43 type of contact : billing, tech, registrant, onsite or accmgr (mandatory)
44  
45 registrant is called licensee by the registry : you can use both names when setting value,
46 but you will get back only registrant when getting.
47  
48 =head2 vat()
49  
50 vat number of contact
51  
52 =head2 lang()
53  
54 language of contact, either fr, nl or en
55  
56 =head1 SUPPORT
57  
58 For now, support questions should be sent to:
59  
60 E<lt>netdri@dotandco.comE<gt>
61  
62 Please also see the SUPPORT file in the distribution.
63  
64 =head1 SEE ALSO
65  
66 http://www.dotandco.com/services/software/Net-DRI/
67  
68 =head1 AUTHOR
69  
70 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
71  
72 =head1 COPYRIGHT
73  
74 Copyright (c) 2006,2008,2009,2013 Patrick Mevzek <netdri@dotandco.com>.
75 All rights reserved.
76  
77 This program is free software; you can redistribute it and/or modify
78 it under the terms of the GNU General Public License as published by
79 the Free Software Foundation; either version 2 of the License, or
80 (at your option) any later version.
81  
82 See the LICENSE file that comes with this distribution for more details.
83  
84 =cut
85  
86 ####################################################################################################
87  
88 sub validate
89 {
90 0 ▶ my ($self,$change)=@_;
Subroutine validate: not called CC=19 SCAR=59.4
Pod undocumented
91 0 ▶ $change||=0;
Condition0%0/2
$change ||= 0
l!l
00
MC/DC0%0/1
$change ||= 0
$change
Truth table0%0/2
A
A= $change
Aresult
11
00
92 0 my @errs;
93  
94 0 $self->SUPER::validate($change); ## will trigger an Exception if problem
95  
96 0 ▶ if (!$change)
Branch: 1 branch
BranchTrueFalseTotal
unless ($change) 0 0 0
97 {
98 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Invalid contact information: voice/type mandatory') unless ($self->voice() && $self->type());
Branch: 1 branch
BranchTrueFalseTotal
unless $self->voice and $self->type 0 0 0
Condition0%0/3
$self->voice and $self->type
!ll&&!rl&&r
000
MC/DC0%0/2
$self->voice and $self->type
$self->voice $self->type
Truth table0%0/3
A and B
A= $self->voiceB= $self->type
ABresult
0X0
100
111
99 }
100  
101 ## Lower limits than in EPP (other checks already done in superclass)
102 0 ▶ push @errs,'name' if ($self->name() && grep { length($_) > 50 } ($self->name()));
Branch: 1 branch
BranchTrueFalseTotal
if $self->name and grep {length $_ > 50;} $self->name 0 0 0
Condition0%0/3
$self->name and grep {length $_ > 50;} $self->name
!ll&&!rl&&r
000
MC/DC0%0/2
$self->name and grep {length $_ > 50;} $self->name
$self->name grep {length $_ > 50;} $self->name
Truth table0%0/3
A and B
A= $self->nameB= grep {length $_ > 50;} $self->name
ABresult
0X0
100
111
103 0 ▶ push @errs,'org' if ($self->org() && grep { length($_) > 100 } ($self->org())); ## docs says only that it will be truncated if more than 100 characters
Branch: 1 branch
BranchTrueFalseTotal
if $self->org and grep {length $_ > 100;} $self->org 0 0 0
Condition0%0/3
$self->org and grep {length $_ > 100;} $self->org
!ll&&!rl&&r
000
MC/DC0%0/2
$self->org and grep {length $_ > 100;} $self->org
$self->org grep {length $_ > 100;} $self->org
Truth table0%0/3
A and B
A= $self->orgB= grep {length $_ > 100;} $self->org
ABresult
0X0
100
111
104  
105  
106 0 ▶ push @errs,'type' if ($self->type() && $self->type()!~m/^(?:billing|tech|registrant|onsite|accmgr)$/); ## licensee is translated to registrant !
Branch: 1 branch
BranchTrueFalseTotal
if $self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite|accmgr)$/ 0 0 0
Condition0%0/3
$self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite|accmgr)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->type and not $self->type =~ /^(?:billing|tech|registrant|onsite|accmgr)$/
$self->type not $self->type =~ /^(?:billing|tech|registrant|onsite|accmgr)$/
Truth table0%0/3
A and not(B)
A= $self->typeB= not $self->type =~ /^(?:billing|tech|registrant|onsite|accmgr)$/
ABresult
0X0
100
111
107 0 ▶ push @errs,'vat' if ($self->vat() && !Net::DRI::Util::xml_is_token($self->vat(),1,20));
Branch: 1 branch
BranchTrueFalseTotal
if $self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20) 0 0 0
Condition0%0/3
$self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->vat and not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
$self->vat not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
Truth table0%0/3
A and not(B)
A= $self->vatB= not Net::DRI::Util::xml_is_token($self->vat, 1, 20)
ABresult
0X0
100
111
108 0 ▶ push @errs,'lang' if ($self->lang() && $self->lang()!~m/^(?:fr|nl|en)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $self->lang and not $self->lang =~ /^(?:fr|nl|en)$/ 0 0 0
Condition0%0/3
$self->lang and not $self->lang =~ /^(?:fr|nl|en)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->lang and not $self->lang =~ /^(?:fr|nl|en)$/
$self->lang not $self->lang =~ /^(?:fr|nl|en)$/
Truth table0%0/3
A and not(B)
A= $self->langB= not $self->lang =~ /^(?:fr|nl|en)$/
ABresult
0X0
100
111
109  
110 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid contact information: '.join('/',@errs)) if @errs;
Branch: 1 branch
BranchTrueFalseTotal
if @errs 0 0 0
111  
112 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Org is mandatory for billing, tech or accmgr contacts') if ($self->type() && $self->type()=~m/^(?:type|billing|accmgr)$/ && !$self->org());
Branch: 1 branch
BranchTrueFalseTotal
if $self->type and $self->type =~ /^(?:type|billing|accmgr)$/ and not $self->org 0 0 0
Condition0%0/6
$self->type and $self->type =~ /^(?:type|billing|accmgr)$/ and not $self->org
!ll&&!rl&&r
000
$self->type and $self->type =~ /^(?:type|billing|accmgr)$/
!ll&&!rl&&r
000
MC/DC0%0/3
$self->type and $self->type =~ /^(?:type|billing|accmgr)$/ and not $self->org
$self->type $self->type =~ /^(?:type|billing|accmgr)$/ not $self->org
Truth table0%0/4
A and B and not(C)
A= $self->typeB= $self->type =~ /^(?:type|billing|accmgr)$/C= not $self->org
ABCresult
0XX0
10X0
1100
1111
113  
114 0 return 1; ## everything ok.
115 }
116  
117 sub init
118 {
119 0 ▶ my ($self,$what,$ndr)=@_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
120 0 ▶ if ($what eq 'create')
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "create") 0 0 0
121 {
122 0 my $a=$self->auth();
123 0 ▶ $self->auth({pw=>''}) unless ($a && (ref($a) eq 'HASH') && exists($a->{pw}));
Branch: 1 branch
BranchTrueFalseTotal
unless $a and ref $a eq "HASH" and exists $a->{"pw"} 0 0 0
Condition0%0/6
$a and ref $a eq "HASH" and exists $a->{"pw"}
!ll&&!rl&&r
000
$a and ref $a eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$a and ref $a eq "HASH" and exists $a->{"pw"}
$a ref $a eq "HASH" exists $a->{"pw"}
Truth table0%0/4
A and B and C
A= $aB= ref $a eq "HASH"C= exists $a->{"pw"}
ABCresult
0XX0
10X0
1100
1111
124 0 ▶ $self->srid('ABCD') unless defined $self->srid(); ## we can not choose the ID
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->srid 0 0 0
125 }
126 0 return;
127 }
128  
129 sub type
130 {
131 0 ▶ my ($self,$what)=@_;
Subroutine type: not called CC=4 SCAR=30.0
Pod documented
132 0 ▶ if (defined $what && $what)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $what and $what) 0 0 0
Condition0%0/3
defined $what and $what
!ll&&!rl&&r
000
MC/DC0%0/2
defined $what and $what
defined $what $what
Truth table0%0/3
A and B
A= defined $whatB= $what
ABresult
0X0
100
111
133 {
134 0 ▶ $what='registrant' if $what eq 'licensee';
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "licensee" 0 0 0
135 0 $self->{type}=$what;
136 0 return $self;
137 }
138 0 return $self->{type};
139 }
140  
141 ####################################################################################################
142 1 1;
« DRI/Protocol/EPP/Extensions/NO/Domain.pm ↑ Summary DRI/Protocol/EPP/Extensions/CAT/DefensiveRegistration.pm »