| 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.15.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); | |||||||||||||
| 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 | 11 | ▶ | sub from_wire { | ||||||||||||
|
Subroutine
from_wire: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||
| 19 | 11 | my ($class, $body) = @_; | |||||||||||||
| 20 | 11 | my %answer = (domain => $body->{domain}); | |||||||||||||
| 21 | 11 | for my $flag (@FLAGS, @MARKERS) { | |||||||||||||
| 22 | 88 | ▶ | next unless exists $body->{$flag}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 70 | ▶ | $answer{$flag} = defined $body->{$flag} ? ($body->{$flag} ? 1 : 0) : undef; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | } | ||||||||||||||
| 25 | 11 | for my $member (@MEMBERS) { | |||||||||||||
| 26 | 33 | ▶ | $answer{$member} = $body->{$member} if exists $body->{$member}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | } | ||||||||||||||
| 28 | 11 | return bless { %answer, _raw => $body }, $class; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 25 | ▶ | sub has { | ||||||||||||
|
Subroutine
has: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 32 | 25 | my ($self, $field) = @_; | |||||||||||||
| 33 | 25 | ▶ | Carp::croak("InternetData::DomainResult::has: unknown field '$field'") unless $KNOWN{$field}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | 24 | ▶ | return exists $self->{$field} ? 1 : 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | 46 | ▶ | *{__PACKAGE__ . "::$field"} = sub { $_[0]->{$field} }; | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 8 | 1; | |||||||||||||
| 52 | |||||||||||||||
| 53 | __END__ | ||||||||||||||