blib/lib/GraphQL/Houtou/Type/List.pm

filter: Statementstmt 66.2% 49 / 74 Branchbran 42.8% 12 / 28 Conditioncond 58.8% 10 / 17 MC/DCmcdc 36.3% 4 / 11 Subroutinesub 76.4% 13 / 17 Podpod 0.0% 0 / 10 totaltotal 56.0% 88 / 157 CC 21 SCAR 18.7
CC
21
Cov
60%
perl_to_graphql
20.0
is_valid
12.0
new
8.5
CRAP 6.5
« blib/lib/GraphQL/Houtou.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/ExecState.pm »
1 package GraphQL::Houtou::Type::List;
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 62 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 62 ▶use parent 'GraphQL::Houtou::Type';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 62 ▶use Role::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 603 ▶sub new {
Subroutine new: called CC=8 SCAR=21.4
Pod undocumented
12 603 my ($class, %args) = @_;
13 603 ▶ croak "Type::List->new requires 'of'\n" if !exists $args{of};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"of"} 0 603 603
14  
15 my $self = bless {
16 of => $args{of},
17 603 ▶ is_introspection => $args{is_introspection} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_introspection'} ? : 0 603 603
18 }, $class;
19  
20 603 my $of = $self->{of};
21 603 my @roles;
22 603 ▶ push @roles, 'GraphQL::Houtou::Role::Input'
Branch: 1 branch
BranchTrueFalseTotal
if $of->DOES("GraphQL::Houtou::Role::Input") or $of->DOES("GraphQL::Role::Input") 165 438 603
Condition66%2/3
$of->DOES("GraphQL::Houtou::Role::Input") or $of->DOES("GraphQL::Role::Input")
l!l&&r!l&&!r
1650438
MC/DC50%1/2
$of->DOES("GraphQL::Houtou::Role::Input") or $of->DOES("GraphQL::Role::Input")
$of->DOES("GraphQL::Houtou::Role::Input") $of->DOES("GraphQL::Role::Input")
Truth table66%2/3
A or B
A= $of->DOES("GraphQL::Houtou::Role::Input")B= $of->DOES("GraphQL::Role::Input")
ABresult
1X1
011
000
23 if $of->DOES('GraphQL::Houtou::Role::Input') || $of->DOES('GraphQL::Role::Input');
24 603 ▶ push @roles, 'GraphQL::Houtou::Role::Output'
Branch: 1 branch
BranchTrueFalseTotal
if $of->DOES("GraphQL::Houtou::Role::Output") or $of->DOES("GraphQL::Role::Output") 601 2 603
Condition66%2/3
$of->DOES("GraphQL::Houtou::Role::Output") or $of->DOES("GraphQL::Role::Output")
l!l&&r!l&&!r
60102
MC/DC50%1/2
$of->DOES("GraphQL::Houtou::Role::Output") or $of->DOES("GraphQL::Role::Output")
$of->DOES("GraphQL::Houtou::Role::Output") $of->DOES("GraphQL::Role::Output")
Truth table66%2/3
A or B
A= $of->DOES("GraphQL::Houtou::Role::Output")B= $of->DOES("GraphQL::Role::Output")
ABresult
1X1
011
000
25 if $of->DOES('GraphQL::Houtou::Role::Output') || $of->DOES('GraphQL::Role::Output');
26 603 ▶ Role::Tiny->apply_roles_to_object($self, @roles) if @roles;
Branch: 1 branch
BranchTrueFalseTotal
if @roles 603 0 603
27  
28 603 return $self;
29 }
30  
31 0 ▶sub list {
Subroutine list: not called CC=2 SCAR=17.9
Pod undocumented
32 0 ▶ $_[0]->{_houtou_list} ||= __PACKAGE__->new(of => $_[0]);
Condition0%0/3
$_[0]{"_houtou_list"} ||= __PACKAGE__->new("of", $_[0])
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"_houtou_list"} ||= __PACKAGE__->new("of", $_[0])
$_[0]{"_houtou_list"} __PACKAGE__->new("of", $_[0])
Truth table0%0/3
A ||= B
A= $_[0]{"_houtou_list"}B= __PACKAGE__->new("of", $_[0])
ABresult
1X1
011
000
33 }
34  
35 363 ▶sub non_null {
Subroutine non_null: called CC=2 SCAR=7.1
Pod undocumented
36 363 require GraphQL::Houtou::Type::NonNull;
37 363 ▶ $_[0]->{_houtou_non_null} ||= GraphQL::Houtou::Type::NonNull->new(of => $_[0]);
Condition66%2/3
$_[0]{"_houtou_non_null"} ||= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
l!l&&r!l&&!r
672960
MC/DC0%0/2
$_[0]{"_houtou_non_null"} ||= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
$_[0]{"_houtou_non_null"} "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
Truth table66%2/3
A ||= B
A= $_[0]{"_houtou_non_null"}B= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
ABresult
1X1
011
000
38 }
39  
40 25266 ▶sub of {
Subroutine of: called CC=1 SCAR=0.0
Pod undocumented
41 25266 return $_[0]->{of};
42 }
43  
44 2213 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
45 2213 return $_[0]->of->name;
46 }
47  
48 12567 ▶sub to_string {
Subroutine to_string: called CC=2 SCAR=6.9
Pod undocumented
49 12567 ▶ $_[0]->{to_string} ||= '[' . $_[0]->of->to_string . ']';
Condition100%2/2
$_[0]{"to_string"} ||= '[' . $_[0]->of->to_string . ']'
l!l
12105462
MC/DC100%1/1
$_[0]{"to_string"} ||= '[' . $_[0]->of->to_string . ']'
$_[0]{"to_string"}
Truth table100%2/2
A
A= $_[0]{"to_string"}
Aresult
11
00
50 }
51  
52 0 ▶sub is_valid {
Subroutine is_valid: not called CC=3 SCAR=24.8
Pod undocumented
53 0 my ($self, $item) = @_;
54 0 my $of = $self->of;
55  
56 0 ▶ return 1 if !defined $item;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item 0 0 0
57 0 ▶ return if grep { !$of->is_valid($_) } @{ $self->uplift($item) };
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $of->is_valid($_);} @{$self->uplift($item);} 0 0 0
58 0 return 1;
59 }
60  
61 835 ▶sub uplift {
Subroutine uplift: called CC=3 SCAR=11.0
Pod undocumented
62 835 my ($self, $item) = @_;
63 835 ▶ return $item if ref($item) eq 'ARRAY' || !defined $item;
Branch: 1 branch
BranchTrueFalseTotal
if ref $item eq "ARRAY" or not defined $item 834 1 835
Condition66%2/3
ref $item eq "ARRAY" or not defined $item
l!l&&r!l&&!r
83401
MC/DC50%1/2
ref $item eq "ARRAY" or not defined $item
ref $item eq "ARRAY" not defined $item
Truth table66%2/3
A or not(B)
A= ref $item eq "ARRAY"B= not defined $item
ABresult
1X1
011
000
64 1 return [ $item ];
65 }
66  
67 835 ▶sub graphql_to_perl {
Subroutine graphql_to_perl: called CC=4 SCAR=14.0
Pod undocumented
68 835 my ($self, $item) = @_;
69 835 my $of = $self->of;
70 835 my $i = 0;
71 835 my @errors;
72 my @values;
73  
74 835 ▶ return $item if !defined $item;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item 0 835 835
75 835 $item = $self->uplift($item);
76 @values = map {
77 835 my $value = eval { $of->graphql_to_perl($_) };
78 3492 ▶ push @errors, qq{In element #$i: $@} if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3492 3492
79 3492 $i++;
80 3492 $value;
81 } @$item;
82 835 ▶ die @errors if @errors;
Branch: 1 branch
BranchTrueFalseTotal
if @errors 0 835 835
83 835 return \@values;
84 }
85  
86 0 ▶sub perl_to_graphql {
Subroutine perl_to_graphql: not called CC=4 SCAR=30.0
Pod undocumented
87 0 my ($self, $item) = @_;
88 0 my $of = $self->of;
89 0 my $i = 0;
90 0 my @errors;
91 my @values;
92  
93 0 ▶ return $item if !defined $item;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item 0 0 0
94 0 $item = $self->uplift($item);
95 @values = map {
96 0 my $value = eval { $of->perl_to_graphql($_) };
97 0 ▶ push @errors, qq{In element #$i: $@} if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
98 0 $i++;
99 0 $value;
100 } @$item;
101 0 ▶ die @errors if @errors;
Branch: 1 branch
BranchTrueFalseTotal
if @errors 0 0 0
102 0 return \@values;
103 }
104  
105 0 ▶sub _complete_value {
Subroutine _complete_value: not called CC=1 SCAR=6.9
106 0 my ($self) = @_;
107 0 die "Type::List->_complete_value is part of the removed legacy execution path; use GraphQL::Houtou::Schema->build_runtime or ->build_native_runtime for list completion on '@{[$self->to_string]}'.\n";
108 }
109  
110 62 1;
111  
112 __END__
« blib/lib/GraphQL/Houtou.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/ExecState.pm »