LogicBoxes/Contact/CA.pm

filter: Statementstmt 49.1% 28 / 57 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 70.0% 7 / 10 Podpod 66.6% 2 / 3 totaltotal 40.2% 37 / 92 CC 9 SCAR 28.4
CC
9
Cov
37%
BUILD
42.0
construct_from_response
12.0
construct_creation_request
6.0
CRAP 17.1
« LogicBoxes/Role/Command/Domain/PrivateNameServer.pm ↑ Summary LogicBoxes/Role/Command/Domain.pm »
1 package WWW::LogicBoxes::Contact::CA;
2  
3 51 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 51 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 51 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 51 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 51 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 51 ▶use WWW::LogicBoxes::Types qw( CPR CPRIndividual CPRNonIndividual Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 51 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 51 extends 'WWW::LogicBoxes::Contact';
15  
16 51 our $VERSION = '1.11.0'; # VERSION
17 # ABSTRACT: Contact for .CA Registrations
18  
19 51 has '+type' => (
20 default => 'CaContact',
21 );
22  
23 51 has 'cpr' => (
24 is => 'ro',
25 isa => CPR,
26 required => 1,
27 );
28  
29 51 has 'agreement_version' => (
30 is => 'ro',
31 isa => Str,
32 required => 0,
33 predicate => 'has_agreement_version',
34 );
35  
36 0 ▶sub BUILD {
Subroutine BUILD: not called CC=6 SCAR=37.4
Pod undocumented
37 0 my $self = shift;
38  
39 0 ▶ if( $self->type ne 'CaContact' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type ne "CaContact") 0 0 0
40 0 croak 'CA Contacts must have a type of CaContact';
41 }
42  
43 0 ▶ if( !$self->has_id && !$self->has_agreement_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_id or $self->has_agreement_version) 0 0 0
Condition0%0/3
$self->has_id or $self->has_agreement_version
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->has_id or $self->has_agreement_version
$self->has_id $self->has_agreement_version
Truth table0%0/3
A or B
A= $self->has_idB= $self->has_agreement_version
ABresult
1X1
011
000
44 0 croak 'An agreement_version must be provided for new CA Contacts';
45 }
46  
47 0 ▶ if( grep { $_ eq $self->cpr } @{ CPRNonIndividual->values } && $self->company ne 'N/A' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $self->cpr;} @{CPRNonIndividual()->values;} && $self->company ne "N/A") 0 0 0
Condition0%0/3
@{CPRNonIndividual()->values;} && $self->company ne 'N/A'
!ll&&!rl&&r
000
MC/DC0%0/2
@{CPRNonIndividual()->values;} && $self->company ne 'N/A'
@{CPRNonIndividual()->values;} $self->company ne 'N/A'
Truth table0%0/3
A && B
A= @{CPRNonIndividual()->values;}B= $self->company ne 'N/A'
ABresult
0X0
100
111
48 0 croak 'For Non Individual CA Contacts the company must be "N/A"';
49 }
50  
51 0 return $self;
52 }
53  
54 0 ▶sub construct_creation_request {
Subroutine construct_creation_request: not called CC=2 SCAR=17.9
Pod documented
55 0 my $self = shift;
56  
57 0 my $request = $self->SUPER::construct_creation_request();
58  
59 0 $request->{'attr-name1'} = 'CPR';
60 0 $request->{'attr-value1'} = $self->cpr;
61  
62 0 ▶ if( $self->has_agreement_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_agreement_version) 0 0 0
63 0 $request->{'attr-name2'} = 'AgreementVersion';
64 0 $request->{'attr-value2'} = $self->agreement_version;
65  
66 0 $request->{'attr-name3'} = 'AgreementValue';
67 0 $request->{'attr-value3'} = 'y';
68 }
69  
70 0 return $request;
71 }
72  
73 0 ▶sub construct_from_response {
Subroutine construct_from_response: not called CC=3 SCAR=24.8
Pod documented
74 0 my $self = shift;
75 0 my $response = shift;
76  
77 0 ▶ if( !defined $response ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $response) 0 0 0
78 0 return;
79 }
80  
81 0 my $contact = WWW::LogicBoxes::Contact->construct_from_response( $response );
82  
83 0 ▶ if( !defined $contact ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $contact) 0 0 0
84 0 return;
85 }
86  
87 $self->meta->rebless_instance( $contact,
88 cpr => $response->{CPR},
89 0 );
90  
91 0 return $contact;
92 }
93  
94 51 __PACKAGE__->meta->make_immutable;
95 51 1;
96  
97 __END__
« LogicBoxes/Role/Command/Domain/PrivateNameServer.pm ↑ Summary LogicBoxes/Role/Command/Domain.pm »