blib/lib/GraphQL/Houtou/Runtime/Slot.pm

filter: Statementstmt 91.9% 80 / 87 Branchbran 80.0% 48 / 60 Conditioncond 47.5% 19 / 40 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 88.2% 30 / 34 Podpod 0.0% 0 / 22 totaltotal 67.3% 177 / 263 CC 52 SCAR 17.2
CC
52
Cov
79%
new
10.5
_callback_abi_code
9.5
_arg_defs_to_compact
8.9
CRAP 5.6
« blib/lib/GraphQL/Houtou/Directive.pm ↑ Summary blib/lib/GraphQL/Houtou/Type/NonNull.pm »
1 package GraphQL::Houtou::Runtime::Slot;
2  
3 62 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 62 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11452 ▶sub new {
Subroutine new: called CC=9 SCAR=23.5
Pod undocumented
8 11452 my ($class, %args) = @_;
9 my $arg_defs_compact = _normalize_arg_defs(
10 $args{arg_defs_compact},
11 $args{arg_defs},
12 11452 );
13 return bless {
14 schema_slot_key => $args{schema_slot_key},
15 schema_slot_index => $args{schema_slot_index},
16 field_name => $args{field_name},
17 result_name => $args{result_name},
18 accessor => $args{accessor},
19 loader => $args{loader},
20 return_type_name => $args{return_type_name},
21 return_type_kind_code => defined $args{return_type_kind_code} ? $args{return_type_kind_code} : 0,
22 item_non_null => $args{item_non_null} ? 1 : 0,
23 resolver_shape => $args{resolver_shape} || 'DEFAULT',
24 resolver_mode => $args{resolver_mode} || 'DEFAULT',
25 completion_family => $args{completion_family} || 'GENERIC',
26 dispatch_family => $args{dispatch_family} || 'GENERIC',
27 arg_defs_compact => $arg_defs_compact,
28 has_args => $args{has_args} ? 1 : 0,
29 11452 ▶ has_directives => $args{has_directives} ? 1 : 0,
Branch: 4 branches
BranchTrueFalseTotal
defined $args{'return_type_kind_code'} ? : 11452 0 11452
$args{'item_non_null'} ? : 2101 9351 11452
$args{'has_args'} ? : 1505 9947 11452
$args{'has_directives'} ? : 5 11447 11452
Condition50%4/8
$args{'resolver_shape'} || 'DEFAULT'
l!l
114520
$args{'resolver_mode'} || 'DEFAULT'
l!l
114520
$args{'completion_family'} || 'GENERIC'
l!l
114520
$args{'dispatch_family'} || 'GENERIC'
l!l
114520
MC/DC0%0/1
$args{'resolver_shape'} || 'DEFAULT'
$args{'resolver_shape'}
MC/DC0%0/1
$args{'resolver_mode'} || 'DEFAULT'
$args{'resolver_mode'}
MC/DC0%0/1
$args{'completion_family'} || 'GENERIC'
$args{'completion_family'}
MC/DC0%0/1
$args{'dispatch_family'} || 'GENERIC'
$args{'dispatch_family'}
Truth table50%1/2
A
A= $args{'resolver_shape'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'resolver_mode'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'completion_family'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'dispatch_family'}
Aresult
11
00
30 }, $class;
31 }
32  
33 20069 ▶sub schema_slot_key { return $_[0]{schema_slot_key} }
Subroutine schema_slot_key: called CC=1 SCAR=0.0
Pod undocumented
34 30 ▶sub schema_slot_index { return $_[0]{schema_slot_index} }
Subroutine schema_slot_index: called CC=1 SCAR=0.0
Pod undocumented
35 6918 ▶sub field_name { return $_[0]{field_name} }
Subroutine field_name: called CC=1 SCAR=0.0
Pod undocumented
36 0 ▶sub result_name { return $_[0]{result_name} }
Subroutine result_name: not called CC=1 SCAR=6.9
Pod undocumented
37 0 ▶sub accessor { return $_[0]{accessor} }
Subroutine accessor: not called CC=1 SCAR=6.9
Pod undocumented
38 13164 ▶sub loader { return $_[0]{loader} }
Subroutine loader: called CC=1 SCAR=0.0
Pod undocumented
39 2521 ▶sub return_type_name { return $_[0]{return_type_name} }
Subroutine return_type_name: called CC=1 SCAR=0.0
Pod undocumented
40 29 ▶sub return_type_kind_code { return $_[0]{return_type_kind_code} }
Subroutine return_type_kind_code: called CC=1 SCAR=0.0
Pod undocumented
41 0 ▶sub item_non_null { return $_[0]{item_non_null} }
Subroutine item_non_null: not called CC=1 SCAR=6.9
Pod undocumented
42 15108 ▶sub resolver_shape { return $_[0]{resolver_shape} }
Subroutine resolver_shape: called CC=1 SCAR=0.0
Pod undocumented
43 33 ▶sub resolver_mode { return $_[0]{resolver_mode} }
Subroutine resolver_mode: called CC=1 SCAR=0.0
Pod undocumented
44 2525 ▶sub completion_family { return $_[0]{completion_family} }
Subroutine completion_family: called CC=1 SCAR=0.0
Pod undocumented
45 1953 ▶sub dispatch_family { return $_[0]{dispatch_family} }
Subroutine dispatch_family: called CC=1 SCAR=0.0
Pod undocumented
46 2 ▶sub callback_abi_code { return _callback_abi_code($_[0]{resolver_shape}, $_[0]{resolver_mode}) }
Subroutine callback_abi_code: called CC=1 SCAR=0.0
Pod undocumented
47 1 ▶sub arg_defs_compact { return $_[0]{arg_defs_compact} }
Subroutine arg_defs_compact: called CC=1 SCAR=0.0
Pod undocumented
48 1922 ▶sub has_args { return $_[0]{has_args} }
Subroutine has_args: called CC=1 SCAR=0.0
Pod undocumented
49 0 ▶sub has_directives { return $_[0]{has_directives} }
Subroutine has_directives: not called CC=1 SCAR=6.9
Pod undocumented
50  
51 864 ▶sub to_struct {
Subroutine to_struct: called CC=1 SCAR=0.0
Pod undocumented
52 864 my ($self) = @_;
53 return {
54 schema_slot_key => $self->{schema_slot_key},
55 schema_slot_index => $self->{schema_slot_index},
56 field_name => $self->{field_name},
57 result_name => $self->{result_name},
58 accessor => $self->{accessor},
59 loader => _clone_value($self->{loader}),
60 return_type_name => $self->{return_type_name},
61 resolver_shape => $self->{resolver_shape},
62 resolver_mode => $self->{resolver_mode},
63 completion_family => $self->{completion_family},
64 dispatch_family => $self->{dispatch_family},
65 return_type_kind_code => $self->{return_type_kind_code},
66 item_non_null => $self->{item_non_null},
67 arg_defs_compact => _clone_compact($self->{arg_defs_compact}),
68 has_args => $self->{has_args},
69 has_directives => $self->{has_directives},
70 864 };
71 }
72  
73 29648 ▶sub to_native_struct {
Subroutine to_native_struct: called CC=3 SCAR=11.7
Pod undocumented
74 29648 my ($self, %opts) = @_;
75 29648 ▶ my $include_arg_defs = exists $opts{include_arg_defs} ? $opts{include_arg_defs} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'include_arg_defs'} ? : 0 29648 29648
76 return {
77 schema_slot_key => $self->{schema_slot_key},
78 schema_slot_index => $self->{schema_slot_index},
79 field_name => $self->{field_name},
80 result_name => $self->{result_name},
81 accessor => $self->{accessor},
82 loader => _clone_value($self->{loader}),
83 return_type_name => $self->{return_type_name},
84 return_type_kind_code => $self->{return_type_kind_code},
85 item_non_null => $self->{item_non_null},
86 resolver_shape => $self->{resolver_shape},
87 resolver_shape_code => _resolver_shape_code($self->{resolver_shape}),
88 resolver_mode => $self->{resolver_mode},
89 resolver_mode_code => _resolver_mode_code($self->{resolver_mode}),
90 callback_abi_code => _callback_abi_code($self->{resolver_shape}, $self->{resolver_mode}),
91 completion_family => $self->{completion_family},
92 completion_family_code => _family_code($self->{completion_family}),
93 dispatch_family => $self->{dispatch_family},
94 dispatch_family_code => _dispatch_family_code($self->{dispatch_family}),
95 ($include_arg_defs ? (arg_defs => _clone_compact($self->{arg_defs_compact})) : ()),
96 has_args => $self->{has_args},
97 has_directives => $self->{has_directives},
98 29648 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$include_arg_defs ? : 29648 0 29648
99 }
100  
101 16283 ▶sub to_native_compact_struct {
Subroutine to_native_compact_struct: called CC=4 SCAR=14.2
Pod undocumented
102 16283 my ($self, %opts) = @_;
103 16283 ▶ my $include_arg_defs = exists $opts{include_arg_defs} ? $opts{include_arg_defs} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'include_arg_defs'} ? : 0 16283 16283
104 16283 my $native = $self->to_native_struct;
105 return [
106 $native->{field_name},
107 $native->{result_name},
108 $native->{return_type_name},
109 $native->{schema_slot_index},
110 $native->{resolver_shape_code},
111 $native->{completion_family_code},
112 $native->{dispatch_family_code},
113 $native->{return_type_kind_code},
114 $native->{has_args},
115 $native->{has_directives},
116 $native->{resolver_mode_code},
117 ($include_arg_defs ? _clone_compact($self->{arg_defs_compact}) : undef),
118 $native->{callback_abi_code},
119 $native->{item_non_null} ? 1 : 0,
120 $native->{accessor},
121 16283 ▶ ];
Branch: 2 branches
BranchTrueFalseTotal
$include_arg_defs ? : 16283 0 16283
$native->{'item_non_null'} ? : 2734 13549 16283
122 }
123  
124 13155 ▶sub to_native_exec_struct {
Subroutine to_native_exec_struct: called CC=1 SCAR=0.0
Pod undocumented
125 13155 my ($self, %opts) = @_;
126 13155 return $self->to_native_struct(%opts);
127 }
128  
129 29648 ▶sub _resolver_shape_code {
Subroutine _resolver_shape_code: called CC=3 SCAR=11.1
130 29648 my ($shape) = @_;
131 29648 ▶ return 2 if ($shape || q()) eq 'EXPLICIT';
Branch: 1 branch
BranchTrueFalseTotal
if ($shape || "") eq "EXPLICIT" 19563 10085 29648
Condition50%1/2
$shape || ''
l!l
296480
MC/DC0%0/1
$shape || ''
$shape
Truth table50%1/2
A
A= $shape
Aresult
11
00
132 10085 return 1;
133 }
134  
135 29648 ▶sub _resolver_mode_code {
Subroutine _resolver_mode_code: called CC=7 SCAR=19.8
136 29648 my ($mode) = @_;
137 29648 ▶ return 4 if ($mode || q()) eq 'NATIVE_ONE_ARG';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE_ONE_ARG" 12 29636 29648
Condition50%1/2
$mode || ''
l!l
296480
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
138 29636 ▶ return 3 if ($mode || q()) eq 'NATIVE_NO_ARGS';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE_NO_ARGS" 8 29628 29636
Condition50%1/2
$mode || ''
l!l
296360
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
139 29628 ▶ return 2 if ($mode || q()) eq 'NATIVE';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE" 130 29498 29628
Condition50%1/2
$mode || ''
l!l
296280
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
140 29498 return 1;
141 }
142  
143 29650 ▶sub _callback_abi_code {
Subroutine _callback_abi_code: called CC=9 SCAR=22.5
144 29650 my ($shape, $mode) = @_;
145 29650 ▶ return 5 if ($mode || q()) eq 'NATIVE_ONE_ARG';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE_ONE_ARG" 13 29637 29650
Condition50%1/2
$mode || ''
l!l
296500
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
146 29637 ▶ return 4 if ($mode || q()) eq 'NATIVE_NO_ARGS';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE_NO_ARGS" 9 29628 29637
Condition50%1/2
$mode || ''
l!l
296370
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
147 29628 ▶ return 3 if ($mode || q()) eq 'NATIVE';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "NATIVE" 130 29498 29628
Condition50%1/2
$mode || ''
l!l
296280
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
148 29498 ▶ return 2 if ($shape || q()) eq 'EXPLICIT';
Branch: 1 branch
BranchTrueFalseTotal
if ($shape || "") eq "EXPLICIT" 19413 10085 29498
Condition50%1/2
$shape || ''
l!l
294980
MC/DC0%0/1
$shape || ''
$shape
Truth table50%1/2
A
A= $shape
Aresult
11
00
149 10085 return 1;
150 }
151  
152 29648 ▶sub _family_code {
Subroutine _family_code: called CC=7 SCAR=19.8
153 29648 my ($family) = @_;
154 29648 ▶ return 2 if ($family || q()) eq 'OBJECT';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "OBJECT" 5171 24477 29648
Condition50%1/2
$family || ''
l!l
296480
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
155 24477 ▶ return 3 if ($family || q()) eq 'LIST';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "LIST" 5782 18695 24477
Condition50%1/2
$family || ''
l!l
244770
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
156 18695 ▶ return 4 if ($family || q()) eq 'ABSTRACT';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "ABSTRACT" 90 18605 18695
Condition50%1/2
$family || ''
l!l
186950
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
157 18605 return 1;
158 }
159  
160 29648 ▶sub _dispatch_family_code {
Subroutine _dispatch_family_code: called CC=7 SCAR=21.1
161 29648 my ($family) = @_;
162 29648 ▶ return 2 if ($family || q()) eq 'RESOLVE_TYPE';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "RESOLVE_TYPE" 0 29648 29648
Condition50%1/2
$family || ''
l!l
296480
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
163 29648 ▶ return 3 if ($family || q()) eq 'TAG';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "TAG" 164 29484 29648
Condition50%1/2
$family || ''
l!l
296480
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
164 29484 ▶ return 4 if ($family || q()) eq 'POSSIBLE_TYPES';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "POSSIBLE_TYPES" 0 29484 29484
Condition50%1/2
$family || ''
l!l
294840
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
165 29484 return 1;
166 }
167  
168 145016 ▶sub _clone_value {
Subroutine _clone_value: called CC=4 SCAR=14.0
169 145016 my ($value) = @_;
170 145016 my $ref = ref($value);
171 145016 ▶ return $value if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 66410 78606 145016
172 78606 ▶ return [ map { _clone_value($_) } @$value ] if $ref eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "ARRAY" 68379 10227 78606
173 10227 ▶ return { map { $_ => _clone_value($value->{$_}) } keys %$value } if $ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HASH" 10227 0 10227
174 0 return $value;
175 }
176  
177 58218 ▶sub _clone_compact {
Subroutine _clone_compact: called CC=2 SCAR=7.1
178 58218 my ($value) = @_;
179 58218 ▶ return undef if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 58218 58218
180 58218 return _clone_value($value);
181 }
182  
183 11452 ▶sub _normalize_arg_defs {
Subroutine _normalize_arg_defs: called CC=3 SCAR=11.0
184 11452 my ($compact, $hash) = @_;
185 11452 ▶ if (defined $compact) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compact) 11423 29 11452
186 11423 ▶ return _arg_defs_to_compact($compact) if ref($compact) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $compact eq "HASH" 0 11423 11423
187 11423 return _clone_compact($compact);
188 }
189 29 return _arg_defs_to_compact($hash);
190 }
191  
192 29 ▶sub _arg_defs_to_compact {
Subroutine _arg_defs_to_compact: called CC=5 SCAR=21.9
193 29 my ($arg_defs) = @_;
194 29 my @entries;
195 29 ▶ for my $name (sort keys %{ $arg_defs || {} }) {
Condition50%1/2
$arg_defs || {}
l!l
029
MC/DC0%0/1
$arg_defs || {}
$arg_defs
Truth table50%1/2
A
A= $arg_defs
Aresult
11
00
196 0 ▶ my $def = $arg_defs->{$name} || {};
Condition0%0/2
$arg_defs->{$name} || {}
l!l
00
MC/DC0%0/1
$arg_defs->{$name} || {}
$arg_defs->{$name}
Truth table0%0/2
A
A= $arg_defs->{$name}
Aresult
11
00
197 push @entries, [
198 $name,
199 $def->{type},
200 $def->{has_default} ? 1 : 0,
201 0 ▶ _clone_value($def->{default_value}),
Branch: 1 branch
BranchTrueFalseTotal
$def->{'has_default'} ? : 0 0 0
202 ];
203 }
204 29 return \@entries;
205 }
206  
207 62 1;
« blib/lib/GraphQL/Houtou/Directive.pm ↑ Summary blib/lib/GraphQL/Houtou/Type/NonNull.pm »