ARIN/Customer.pm

filter: Statementstmt 43.7% 21 / 48 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 3 / 3 totaltotal 51.4% 36 / 70 CC 8 SCAR 17.2
CC
8
Cov
47%
dump
12.0
AUTOLOAD
5.9
contacts
2.0
CRAP 5.6
« ARIN/Network.pm ↑ Summary ARIN/AS.pm »
1 package Net::Whois::ARIN::Customer;
2  
3 =head1 NAME
4  
5 Net::Whois::ARIN::Customer - ARIN whois Customer record class
6  
7 =head1 SYNOPSIS
8  
9 use Net::Whois::ARIN::Customer;
10  
11 my $cust = Net::Whois::ARIN::Customer->new(
12 CustName => 'Electric Lightwave Inc',
13 Address => '4400 NE 77th Ave',
14 City => 'Vancouver',
15 StateProv => 'WA',
16 PostalCode => '98662',
17 Country => 'US',
18 Comment => '',
19 RegDate => '1995-07-25',
20 Updated => '2001-05-17',
21 );
22  
23 printf "%s is located in %s, %s\n",
24 $cust->CustName,
25 $cust->City,
26 $cust->StateProv;
27  
28 =head1 DESCRIPTION
29  
30 The Net::Whois::ARIN::Customer module is simple class which is used to store the attributes of an Customer record in A
31 RIN's Whois server. Each attribute of the Customer record has an accessor/mutator of the same name.
32  
33 =cut
34  
35 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 7 ▶use Carp "croak";
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 7 our $AUTOLOAD;
39  
40 =head1 METHODS
41  
42 =over 4
43  
44 =item B<new> - create a Net::Whois::ARIN::Customer object
45  
46 =back
47  
48 =cut
49  
50 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
51 1 my $class = shift;
52 1 return bless { _contacts => [], @_ }, $class;
53 }
54  
55 =over 4
56  
57 =item B<contacts> - get/set Net::Whois::ARIN::Contact
58  
59 This method accepts a list of Net::Whois::ARIN::Contact and associates these objects with the Organization record. If no argu
60 ments are specified, the method returns a list of Net::Whois::ARIN::Contact objects.
61  
62 =back
63  
64 =cut
65  
66 2 ▶sub contacts {
Subroutine contacts: called CC=2 SCAR=6.9
Pod documented
67 2 my $self = shift;
68 2 ▶ $self->{_contacts} = [ @_ ] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 1 2
69 2 return @{ $self->{_contacts} };
70 }
71  
72 =over 4
73  
74 =item B<dump> - return the current whois record
75  
76 print $o->dump;
77  
78 =back
79  
80 =cut
81  
82 0 ▶sub dump {
Subroutine dump: not called CC=3 SCAR=24.8
Pod documented
83 0 my $self = shift;
84 0 my $record = sprintf "\nCustName: %s\n", $self->CustName;
85 0 $record .= sprintf("Address: %s\n", $_) for @{ $self->Address };
86 0 $record .= sprintf "City: %s\n",$self->City;
87 0 $record .= sprintf "StateProv: %s\n",$self->StateProv;
88 0 $record .= sprintf "PostalCode: %s\n",$self->PostalCode;
89 0 $record .= sprintf "Country: %s\n",$self->Country;
90 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
91 0 $record .= sprintf "Updated: %s\n\n",$self->Updated;
92  
93 0 $record .= sprintf "NetRange: %s\n",$self->NetRange;
94 0 $record .= sprintf "CIDR: %s\n",$self->CIDR;
95 0 $record .= sprintf "NetName: %s\n",$self->NetName;
96 0 $record .= sprintf "NetHandle: %s\n",$self->NetHandle;
97 0 $record .= sprintf "Parent: %s\n",$self->Parent;
98 0 $record .= sprintf "NetType: %s\n",$self->NetType;
99 0 $record .= sprintf "Comment: %s\n",$self->Comment;
100 0 $record .= sprintf "RegDate: %s\n",$self->RegDate;
101 0 $record .= sprintf "Updated: %s\n",$self->Updated;
102  
103 0 foreach my $contact ( $self->contacts ) {
104 0 $record .= sprintf "%sHandle: %s\n", $contact->Type, $contact->Handle;
105 0 $record .= sprintf "%sName: %s\n", $contact->Type, $contact->Name;
106 0 $record .= sprintf "%sPhone: %s\n", $contact->Type, $contact->Phone;
107 0 $record .= sprintf "%sEmail: %s\n", $contact->Type, $contact->Email;
108 }
109  
110 0 return $record;
111 }
112  
113 =head1 ATTRIBUTES
114  
115 These methods are the accessors/mutators for the fields found in the Whois record.
116  
117 =over 4
118  
119 =item B<CustName> - get/set the customer name
120  
121 =item B<Address> - get/set the address
122  
123 =item B<City> - get/set the city
124  
125 =item B<StateProv> - get/set the state or province
126  
127 =item B<PostalCode> - get/set the postal code
128  
129 =item B<Country> - get/set the country
130  
131 =item B<RegDate> - get/set the registration date
132  
133 =item B<Updated> - get/set the last updated date
134  
135 =item B<NetRange> - get/set the network range
136  
137 =item B<CIDR> - get/set the CIDR netblock
138  
139 =item B<NetName> - get/set the network name
140  
141 =item B<NetHandle> - get/set the network handle
142  
143 =item B<Parent> - get/set the parent network handle
144  
145 =item B<NetType> - get/set the network type
146  
147 =item B<Comment> - get/set the public comment
148  
149 =back
150  
151 =cut
152  
153 16 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=17.8
154 16 my $self = shift;
155 16 my $name = $AUTOLOAD;
156 16 $name =~ s/.*://;
157  
158 16 ▶ return if $name eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "DESTROY" 1 15 16
159  
160 15 ▶ if ($name !~ /^_/ && exists $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $name =~ /^_/ and exists $self->{$name}) 15 0 15
Condition33%1/3
not $name =~ /^_/ and exists $self->{$name}
!ll&&!rl&&r
0015
MC/DC0%0/2
not $name =~ /^_/ and exists $self->{$name}
not $name =~ /^_/ exists $self->{$name}
Truth table33%1/3
not(A) and B
A= not $name =~ /^_/B= exists $self->{$name}
ABresult
0X0
100
111
161 15 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 15 15
162 0 return $self->{$name} = shift;
163 } else {
164 15 return $self->{$name};
165 }
166 }
167  
168 0 croak "Undefined subroutine \&$AUTOLOAD called";
169 }
170  
171 =head1 AUTHOR
172  
173 Todd Caine <todd.caine at gmail.com>
174  
175 =head1 COPYRIGHT AND LICENSE
176  
177 Copyright (c) 2004-2011 Todd Caine. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
178  
179 =cut
180  
181 7 1;
182 __END__
« ARIN/Network.pm ↑ Summary ARIN/AS.pm »