InternetData/DomainResult.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 75.0% 3 / 4 totaltotal 90.4% 57 / 63 CC 9 SCAR 13.6
CC
9
Cov
92%
from_wire
7.0
has
3.0
fields
2.0
CRAP 3.9
« InternetData/Cache.pm ↑ Summary InternetData/AsnResult.pm »
1 package InternetData::DomainResult;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 our $VERSION = '1.16.0';
9  
10 8 our @FLAGS = qw(is_registered is_disposable has_a has_aaaa has_mx has_ns has_cname);
11 # Copied as served, and paid: absent from an answer whose plan leaves them out.
12 8 our @MEMBERS = qw(dns ip_ranges disposable);
13 8 our @MARKERS = qw(trial_expired cap_reached);
14  
15 8 my %KNOWN = map { $_ => 1 } 'domain', @FLAGS, @MEMBERS, @MARKERS;
16  
17 # Copied on key PRESENCE, never on truthiness, as InternetData::Result is.
18 12 ▶sub from_wire {
Subroutine from_wire: called CC=7 SCAR=19.5
Pod undocumented
19 12 my ($class, $body) = @_;
20 12 my %answer = (domain => $body->{domain});
21 12 for my $flag (@FLAGS, @MARKERS) {
22 108 ▶ next unless exists $body->{$flag};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $body->{$flag} 30 78 108
23 78 ▶ $answer{$flag} = defined $body->{$flag} ? ($body->{$flag} ? 1 : 0) : undef;
Branch: 2 branches
BranchTrueFalseTotal
defined $body->{$flag} ? : 78 0 78
$body->{$flag} ? : 27 51 78
24 }
25 12 for my $member (@MEMBERS) {
26 36 ▶ $answer{$member} = $body->{$member} if exists $body->{$member};
Branch: 1 branch
BranchTrueFalseTotal
if exists $body->{$member} 5 31 36
27 }
28 12 return bless { %answer, _raw => $body }, $class;
29 }
30  
31 40 ▶sub has {
Subroutine has: called CC=3 SCAR=11.0
Pod documented
32 40 my ($self, $field) = @_;
33 40 ▶ Carp::croak("InternetData::DomainResult::has: unknown field '$field'") unless $KNOWN{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless $KNOWN{$field} 1 39 40
34 39 ▶ return exists $self->{$field} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{$field} ? : 28 11 39
35 }
36  
37 0 ▶sub fields {
Subroutine fields: not called CC=1 SCAR=6.9
Pod documented
38 0 my ($self) = @_;
39 0 return grep { exists $self->{$_} } @FLAGS, @MEMBERS, @MARKERS;
40 }
41  
42 1 ▶sub raw {
Subroutine raw: called CC=1 SCAR=0.0
Pod documented
43 1 return $_[0]->{_raw};
44 }
45  
46 8 for my $field ('domain', @FLAGS, @MEMBERS, @MARKERS) {
47 8 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
48 70 ▶ *{__PACKAGE__ . "::$field"} = sub { $_[0]->{$field} };
Subroutine __ANON__: called CC=1 SCAR=0.0
49 }
50  
51 8 1;
52  
53 __END__
« InternetData/Cache.pm ↑ Summary InternetData/AsnResult.pm »