blib/lib/WWW/eNom/Types.pm

filter: Statementstmt 81.6% 71 / 87 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 46.1% 12 / 26 Podpod n/a totaltotal 73.4% 83 / 113 CC 1 SCAR 1.6
CC
1
Cov
82%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.2
« blib/lib/WWW/eNom/PhoneNumber.pm ↑ Summary blib/lib/Net/eNom.pm »
1 package WWW::eNom::Types;
2  
3 81 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 81 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 81 ▶use Data::Validate::IP qw( is_ipv4 is_ipv6 );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 81 ▶use Data::Validate::Domain qw( is_domain );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 81 ▶use Data::Validate::Email qw( is_email );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 81 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 81 our $VERSION = 'v2.0.0'; # VERSION
12 # ABSTRACT: WWW::eNom Moose Type Library
13  
14 81 use MooseX::Types -declare => [qw(
15 ArrayRef
16 Bool
17 HashRef
18 Int
19 PositiveInt
20 Str
21 Strs
22  
23 IP
24 IPs
25 IPv4
26 IPv4s
27 IPv6
28 IPv6s
29  
30 ContactType
31 DateTime
32 DomainName
33 DomainNames
34 EmailAddress
35 HTTPTiny
36 NexusPurpose
37 NexusCategory
38 NumberPhone
39 ResponseType
40 TransferVerificationMethod
41 URI
42  
43 Contact
44 Domain
45 DomainAvailability
46 DomainAvailabilities
47 DomainRegistration
48 DomainTransfer
49 PhoneNumber
50 PrivateNameServer
51 PrivateNameServers
52 81 ▶)];
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54 use MooseX::Types::Moose
55 81 ArrayRef => { -as => 'MooseArrayRef' },
56 Bool => { -as => 'MooseBool' },
57 HashRef => { -as => 'MooseHashRef' },
58 Int => { -as => 'MooseInt' },
59 81 ▶ Str => { -as => 'MooseStr' };
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 81 subtype ArrayRef, as MooseArrayRef;
62 81 subtype Bool, as MooseBool;
63 81 subtype HashRef, as MooseHashRef;
64 81 subtype Int, as MooseInt;
65 81 subtype Str, as MooseStr;
66 81 subtype Strs, as ArrayRef[Str];
67  
68 81 enum ContactType, [qw( Registrant Tech Admin AuxBilling )];
69 81 enum NexusCategory, [qw( C11 C12 C21 C31 C32 )];
70 81 enum NexusPurpose, [qw( P1 P2 P3 P4 P5 )];
71  
72 subtype DomainName, as Str,
73 191 ▶ where { is_domain( $_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
74 0 ▶ message { "$_ is not a valid domain" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
75 81 subtype DomainNames, as ArrayRef[DomainName];
76  
77 subtype EmailAddress, as Str,
78 45 ▶ where { is_email( $_ ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
79 0 ▶ message { "$_ is not a valid email address" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
80  
81 subtype PositiveInt, as Int,
82 58 ▶ where { $_ > 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
83 0 ▶ message { "$_ is not a positive integer" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
84  
85 81 my @response_types = qw( xml xml_simple html text );
86 subtype ResponseType, as Str,
87 where {
88 0 ▶ my $response_type = $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
89 0 grep { $response_type eq $_ } @response_types;
90 },
91 0 ▶ message { 'response_type must be one of: ' . join ', ', @response_types };
Subroutine __ANON__: not called CC=1 SCAR=1.2
92  
93 81 class_type DateTime, { class => 'DateTime' };
94 81 class_type HTTPTiny, { class => 'HTTP::Tiny' };
95 81 class_type NumberPhone, { class => 'Number::Phone' };
96 81 class_type URI, { class => 'URI' };
97 0 ▶coerce URI, from Str, via { URI->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
98  
99 81 enum TransferVerificationMethod, [qw( Fax Autoverification )];
100  
101 81 class_type Contact, { class => 'WWW::eNom::Contact' };
102 81 class_type Domain, { class => 'WWW::eNom::Domain' };
103 81 class_type DomainAvailability, { class => 'WWW::eNom::DomainAvailability' };
104 81 subtype DomainAvailabilities, as ArrayRef[DomainAvailability];
105  
106 81 class_type DomainRegistration, { class => 'WWW::eNom::DomainRequest::Registration' };
107 0 ▶coerce DomainRegistration, from HashRef, via { WWW::eNom::DomainRequest::Registration->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
108  
109 81 class_type DomainTransfer, { class => 'WWW::eNom::DomainRequest::Transfer' };
110 0 ▶coerce DomainTransfer, from HashRef, via { WWW::eNom::DomainRequest::Transfer->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
111  
112 81 class_type PhoneNumber, { class => 'WWW::eNom::PhoneNumber' };
113 coerce PhoneNumber, from Str,
114 48 ▶ via { WWW::eNom::PhoneNumber->new( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
115 coerce PhoneNumber, from NumberPhone,
116 0 ▶ via { WWW::eNom::PhoneNumber->new( $_->format ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
117  
118 81 class_type PrivateNameServer, { class => 'WWW::eNom::PrivateNameServer' };
119 coerce PrivateNameServer, from HashRef,
120 0 ▶ via { WWW::eNom::PrivateNameServer->new( $_ ) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
121 81 subtype PrivateNameServers, as ArrayRef[PrivateNameServer];
122  
123 subtype IPv4, as Str,
124 0 ▶ where { is_ipv4( $_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
125 0 ▶ message { "$_ is not a valid ipv4 IP Address" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
126 81 subtype IPv4s, as ArrayRef[IPv4];
127  
128 subtype IPv6, as Str,
129 0 ▶ where { is_ipv6( $_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
130 0 ▶ message { "$_ is not a valid ipv6 IP Address" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
131 81 subtype IPv6s, as ArrayRef[IPv6];
132  
133 81 subtype IP, as IPv4 | IPv6;
134 81 subtype IPs, as ArrayRef[IP];
135  
136 81 1;
137  
138 __END__
« blib/lib/WWW/eNom/PhoneNumber.pm ↑ Summary blib/lib/Net/eNom.pm »