v1/Role/ObjectMethods.pm

filter: Statementstmt 52.5% 31 / 59 Branchbran 34.6% 9 / 26 Conditioncond 30.0% 9 / 30 MC/DCmcdc 15.0% 3 / 20 Subroutinesub 53.8% 7 / 13 Podpod n/a totaltotal 39.8% 59 / 148 CC 31 SCAR 41.8
CC
31
Cov
43%
__ANON__
132.0
__ANON__
71.5
__ANON__
56.0
CRAP 65.3
« v1.pm ↑ Summary v1/Role/REST/Client.pm »
1 package Net::Checkpoint::Management::v1::Role::ObjectMethods;
2 3 $Net::Checkpoint::Management::v1::Role::ObjectMethods::VERSION = '0.004003';
3 # ABSTRACT: Role for Checkpoint Management API version 1.x method generation
4  
5 3 ▶use 5.024;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use MooX::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp::Clan qw(^Net::Checkpoint::Management::v1);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Moo::Role; # last for cleanup
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 requires qw( _create _list _get _update _delete );
14  
15  
16  
17  
18  
19  
20  
21  
22 32 ▶role {
Subroutine __ANON__: called CC=13 SCAR=42.7
23 32 my $params = shift;
24 32 my $mop = shift;
25  
26 32 ▶ if (exists $params->{singular} && defined $params->{singular}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params->{"singular"} and defined $params->{"singular"}) 32 0 32
Condition33%1/3
exists $params->{"singular"} and defined $params->{"singular"}
!ll&&!rl&&r
0032
MC/DC0%0/2
exists $params->{"singular"} and defined $params->{"singular"}
exists $params->{"singular"} defined $params->{"singular"}
Truth table33%1/3
A and B
A= exists $params->{"singular"}B= defined $params->{"singular"}
ABresult
0X0
100
111
27 0 ▶ $mop->method('create_' . $params->{singular} => sub ($self, $object_data) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 return $self->_create(join('/',
29 '/web_api',
30 'v' . $self->api_version,
31 $params->{create}
32 0 ), $object_data);
33 })
34 32 ▶ if exists $params->{create} && defined $params->{create};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"create"} and defined $params->{"create"} 28 4 32
Condition66%2/3
exists $params->{"create"} and defined $params->{"create"}
!ll&&!rl&&r
4028
MC/DC50%1/2
exists $params->{"create"} and defined $params->{"create"}
exists $params->{"create"} defined $params->{"create"}
Truth table66%2/3
A and B
A= exists $params->{"create"}B= defined $params->{"create"}
ABresult
0X0
100
111
35  
36 0 ▶ $mop->method('get_' . $params->{singular} => sub ($self, $query_params = {}) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
37 return $self->_get(join('/',
38 '/web_api',
39 'v' . $self->api_version,
40 $params->{get}
41 0 ), $query_params);
42 })
43 32 ▶ if exists $params->{get} && defined $params->{get};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"get"} and defined $params->{"get"} 32 0 32
Condition33%1/3
exists $params->{"get"} and defined $params->{"get"}
!ll&&!rl&&r
0032
MC/DC0%0/2
exists $params->{"get"} and defined $params->{"get"}
exists $params->{"get"} defined $params->{"get"}
Truth table33%1/3
A and B
A= exists $params->{"get"}B= defined $params->{"get"}
ABresult
0X0
100
111
44  
45 0 ▶ $mop->method('update_' . $params->{singular} => sub ($self, $object, $object_data) {
Subroutine __ANON__: not called CC=7 SCAR=40.3
46 0 my $updated_data = { %$object, %$object_data };
47 0 ▶ if (exists $params->{id_keys} && ref $params->{id_keys} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params->{"id_keys"} and ref $params->{"id_keys"} eq "ARRAY") 0 0 0
Condition0%0/3
exists $params->{"id_keys"} and ref $params->{"id_keys"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $params->{"id_keys"} and ref $params->{"id_keys"} eq "ARRAY"
exists $params->{"id_keys"} ref $params->{"id_keys"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $params->{"id_keys"}B= ref $params->{"id_keys"} eq "ARRAY"
ABresult
0X0
100
111
48 # ensure that only a single key is passed to the update call
49 # the order of keys is the priority
50 0 my @id_keys = $params->{id_keys}->@*;
51 0 ▶ while (my $key = shift @id_keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift @id_keys) 0 0 0
52 last
53 if exists $updated_data->{$key}
54 0 ▶ && defined $updated_data->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $updated_data->{$key} and defined $updated_data->{$key} 0 0 0
Condition0%0/3
exists $updated_data->{$key} and defined $updated_data->{$key}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $updated_data->{$key} and defined $updated_data->{$key}
exists $updated_data->{$key} defined $updated_data->{$key}
Truth table0%0/3
A and B
A= exists $updated_data->{$key}B= defined $updated_data->{$key}
ABresult
0X0
100
111
55 }
56 delete $updated_data->{$_}
57 0 for @id_keys;
58 }
59  
60 return $self->_update(join('/',
61 '/web_api',
62 'v' . $self->api_version,
63 $params->{update}
64 0 ), $updated_data);
65 })
66 32 ▶ if exists $params->{update} && defined $params->{update};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"update"} and defined $params->{"update"} 30 2 32
Condition66%2/3
exists $params->{"update"} and defined $params->{"update"}
!ll&&!rl&&r
2030
MC/DC50%1/2
exists $params->{"update"} and defined $params->{"update"}
exists $params->{"update"} defined $params->{"update"}
Truth table66%2/3
A and B
A= exists $params->{"update"}B= defined $params->{"update"}
ABresult
0X0
100
111
67  
68 0 ▶ $mop->method('delete_' . $params->{singular} => sub ($self, $object) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 return $self->_delete(join('/',
70 '/web_api',
71 'v' . $self->api_version,
72 $params->{delete}
73 0 ), $object);
74 })
75 32 ▶ if exists $params->{delete} && defined $params->{delete};
Branch: 1 branch
BranchTrueFalseTotal
if exists $params->{"delete"} and defined $params->{"delete"} 28 4 32
Condition66%2/3
exists $params->{"delete"} and defined $params->{"delete"}
!ll&&!rl&&r
4028
MC/DC50%1/2
exists $params->{"delete"} and defined $params->{"delete"}
exists $params->{"delete"} defined $params->{"delete"}
Truth table66%2/3
A and B
A= exists $params->{"delete"}B= defined $params->{"delete"}
ABresult
0X0
100
111
76  
77 0 ▶ $mop->method('find_' . $params->{singular} => sub ($self, $search_params = {}, $query_params = {}) {
Subroutine __ANON__: not called CC=11 SCAR=48.8
78 0 my $listname = 'list_' . $params->{object};
79 0 my $list_key = $params->{list_key};
80 0 for my $object ($self->$listname({ 'details-level' => 'full', %$query_params })->{$list_key}->@*) {
81 0 my $identical = 0;
82 0 for my $key (keys $search_params->%*) {
83 0 ▶ if ( ref $search_params->{$key} eq 'Regexp') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $search_params->{$key} eq 'Regexp') { } 0 0 0
84 0 ▶ if ( exists $object->{$key}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $object->{$key} and $object->{$key} =~ /$search_params->{$key}/u) 0 0 0
Condition0%0/3
exists $object->{$key} and $object->{$key} =~ /$search_params->{$key}/u
!ll&&!rl&&r
000
MC/DC0%0/2
exists $object->{$key} and $object->{$key} =~ /$search_params->{$key}/u
exists $object->{$key} $object->{$key} =~ /$search_params->{$key}/u
Truth table0%0/3
A and B
A= exists $object->{$key}B= $object->{$key} =~ /$search_params->{$key}/u
ABresult
0X0
100
111
85 && $object->{$key} =~ $search_params->{$key}) {
86 0 $identical++;
87 }
88 }
89 else {
90 0 ▶ if ( exists $object->{$key}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $object->{$key} and $object->{$key} eq $search_params->{$key}) 0 0 0
Condition0%0/3
exists $object->{$key} and $object->{$key} eq $search_params->{$key}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $object->{$key} and $object->{$key} eq $search_params->{$key}
exists $object->{$key} $object->{$key} eq $search_params->{$key}
Truth table0%0/3
A and B
A= exists $object->{$key}B= $object->{$key} eq $search_params->{$key}
ABresult
0X0
100
111
91 && $object->{$key} eq $search_params->{$key}) {
92 0 $identical++;
93 }
94 }
95 }
96 0 ▶ if ($identical == scalar keys $search_params->%*) {
Branch: 1 branch
BranchTrueFalseTotal
if ($identical == scalar keys %$search_params) 0 0 0
97 0 return $object;
98 }
99 }
100 0 croak "object not found";
101 32 });
102 }
103  
104 32 ▶ if (exists $params->{object} && defined $params->{object}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params->{"object"} and defined $params->{"object"}) 32 0 32
Condition33%1/3
exists $params->{"object"} and defined $params->{"object"}
!ll&&!rl&&r
0032
MC/DC0%0/2
exists $params->{"object"} and defined $params->{"object"}
exists $params->{"object"} defined $params->{"object"}
Truth table33%1/3
A and B
A= exists $params->{"object"}B= defined $params->{"object"}
ABresult
0X0
100
111
105 0 ▶ $mop->method('list_' . $params->{object} => sub ($self, $query_params = {}) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
106 return $self->_list(join('/',
107 '/web_api',
108 'v' . $self->api_version,
109 $params->{list}
110 0 ), $params->{list_key}, $query_params);
111 32 });
112 }
113 3 };
114  
115 3 1;
116  
117 __END__
« v1.pm ↑ Summary v1/Role/REST/Client.pm »