« blib/lib/GraphQL/Houtou/Validation/DepthLimit.pm
↑ Summary
blib/lib/GraphQL/Houtou/Validation/NodeLimit.pm »
| 1 | package GraphQL::Houtou::Type::Scalar; | ||||||||||||||||||||||||||||
| 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 parent 'GraphQL::Houtou::Type'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 62 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 62 | ▶ | use JSON::MaybeXS qw(JSON is_bool); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 62 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 62 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 62 | ▶ | use GraphQL::Houtou::Internal::TypeSupport qw(description_doc_lines named_from_ast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 62 | ▶ | use GraphQL::Houtou::Type::List (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 62 | ▶ | use GraphQL::Houtou::Type::NonNull (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 62 | with qw( | |||||||||||||||||||||||||||
| 17 | GraphQL::Houtou::Role::Input | ||||||||||||||||||||||||||||
| 18 | GraphQL::Houtou::Role::Output | ||||||||||||||||||||||||||||
| 19 | GraphQL::Houtou::Role::Leaf | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 62 | our @EXPORT_OK = qw($Int $Float $String $Boolean $ID); | |||||||||||||||||||||||||||
| 23 | 62 | ▶ | use constant DEBUG => $ENV{GRAPHQL_DEBUG}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 120 | ▶ | sub list { | ||||||||||||||||||||||||||
|
Subroutine
list: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 120 | ▶ | $_[0]->{_houtou_list} ||= GraphQL::Houtou::Type::List->new(of => $_[0]); | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[0]{"_houtou_list"} ||= "GraphQL::Houtou::Type::List"->new("of", $_[0])
MC/DC0%0/2
$_[0]{"_houtou_list"} ||= "GraphQL::Houtou::Type::List"->new("of", $_[0])
$_[0]{"_houtou_list"}
"GraphQL::Houtou::Type::List"->new("of", $_[0])
Truth table66%2/3
A ||= B
A= $_[0]{"_houtou_list"}B= "GraphQL::Houtou::Type::List"->new("of", $_[0])
| |||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1430 | ▶ | sub non_null { | ||||||||||||||||||||||||||
|
Subroutine
non_null: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 1430 | ▶ | $_[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])
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])
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 620 | ▶ | sub _leave_undef { | ||||||||||||||||||||||||||
|
Subroutine
_leave_undef: called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 34 | 620 | my ($closure) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub { return undef if !defined $_[0]; goto &$closure; }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 368 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 368 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 40 | 368 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||||||||||
| 41 | 368 | $self->{name} = $args{name}; | |||||||||||||||||||||||||||
| 42 | 368 | $self->{description} = $args{description}; | |||||||||||||||||||||||||||
| 43 | 368 | $self->{serialize} = $args{serialize}; | |||||||||||||||||||||||||||
| 44 | 368 | $self->{parse_value} = $args{parse_value}; | |||||||||||||||||||||||||||
| 45 | 368 | $self->{_builtin_kind} = $args{_builtin_kind}; | |||||||||||||||||||||||||||
| 46 | 368 | $self->{specified_by_url} = $args{specified_by_url}; | |||||||||||||||||||||||||||
| 47 | 368 | return bless $self, $class; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 64569 | ▶ | sub name { $_[0]->{name} } | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 4885 | ▶ | sub description { $_[0]->{description} } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 46644 | ▶ | sub to_string { $_[0]->{to_string} ||= $_[0]->name } | ||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=2 SCAR=7.2
Pod
undocumented
Condition66%2/3
$_[0]{"to_string"} ||= $_[0]->name
MC/DC0%0/2
$_[0]{"to_string"} ||= $_[0]->name
$_[0]{"to_string"}
$_[0]->name
Truth table66%2/3
A ||= B
A= $_[0]{"to_string"}B= $_[0]->name
| |||||||||||||||||||||||||||||
| 53 | 4943 | ▶ | sub serialize { $_[0]->{serialize} } | ||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 4892 | ▶ | sub parse_value { $_[0]->{parse_value} } | ||||||||||||||||||||||||||
|
Subroutine
parse_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 49 | ▶ | sub from_ast { | ||||||||||||||||||||||||||
|
Subroutine
from_ast: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 49 | my ($class, $name2type, $ast_node) = @_; | |||||||||||||||||||||||||||
| 58 | 6 | ▶ | my ($specified_by) = grep { ($_->{name} || q()) eq 'specifiedBy' } | ||||||||||||||||||||||||||
|
Condition50%1/2
$_->{'name'} || ''
MC/DC0%0/1
$_->{'name'} || ''
$_->{'name'}
Truth table50%1/2
A
A= $_->{'name'}
| |||||||||||||||||||||||||||||
| 59 | 49 | ▶ | @{ $ast_node->{directives} || [] }; | ||||||||||||||||||||||||||
|
Condition100%2/2
$ast_node->{'directives'} || []
MC/DC100%1/1
$ast_node->{'directives'} || []
$ast_node->{'directives'}
Truth table100%2/2
A
A= $ast_node->{'directives'}
| |||||||||||||||||||||||||||||
| 60 | return $class->new( | ||||||||||||||||||||||||||||
| 61 | named_from_ast($ast_node), | ||||||||||||||||||||||||||||
| 62 | # SDL-built custom scalars default to pass-through coercion; override | ||||||||||||||||||||||||||||
| 63 | # via the resolvers option of Schema->from_doc or by replacing these. | ||||||||||||||||||||||||||||
| 64 | 2 | ▶ | serialize => sub { $_[0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 10 | ▶ | parse_value => sub { $_[0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | ($specified_by && defined $specified_by->{arguments}{url} | ||||||||||||||||||||||||||||
| 67 | ? (specified_by_url => $specified_by->{arguments}{url}) | ||||||||||||||||||||||||||||
| 68 | 49 | ▶ | : ()), | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$specified_by and defined $specified_by->{"arguments"}{"url"}
MC/DC50%1/2
$specified_by and defined $specified_by->{"arguments"}{"url"}
$specified_by
defined $specified_by->{"arguments"}{"url"}
Truth table66%2/3
A and B
A= $specified_byB= defined $specified_by->{"arguments"}{"url"}
| |||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 3 | ▶ | sub to_doc { | ||||||||||||||||||||||||||
|
Subroutine
to_doc: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 74 | 3 | ▶ | return $self->{to_doc} if exists $self->{to_doc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 3 | my $line = "scalar @{[$self->name]}"; | |||||||||||||||||||||||||||
| 76 | 3 | ▶ | if (defined(my $url = $self->specified_by_url)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 3 | $line .= ' @specifiedBy(url: ' | |||||||||||||||||||||||||||
| 78 | . JSON::MaybeXS->new->utf8(0)->allow_nonref->encode($url) . ')'; | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 3 | return $self->{to_doc} = join '', map "$_\n", | |||||||||||||||||||||||||||
| 81 | description_doc_lines($self->description), | ||||||||||||||||||||||||||||
| 82 | $line; | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 7771 | ▶ | sub _builtin_kind { $_[0]->{_builtin_kind} } | ||||||||||||||||||||||||||
|
Subroutine
_builtin_kind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 4890 | ▶ | sub specified_by_url { $_[0]->{specified_by_url} } | ||||||||||||||||||||||||||
|
Subroutine
specified_by_url: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 3863 | ▶ | sub _fast_is_nonref_defined { | ||||||||||||||||||||||||||
|
Subroutine
_fast_is_nonref_defined: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 88 | 3863 | ▶ | defined $_[0] && !ref($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 21 | ▶ | sub _fast_is_int32_signed { | ||||||||||||||||||||||||||
|
Subroutine
_fast_is_int32_signed: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||
| 92 | 21 | ▶ | return if !_fast_is_nonref_defined($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 21 | ▶ | return if !looks_like_number($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 15 | ▶ | return if int($_[0]) != $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 15 | ▶ | return $_[0] >= -2147483648 && $_[0] <= 2147483647; | ||||||||||||||||||||||||||
|
Condition33%1/3
$_[0] >= -2147483648 && $_[0] <= 2147483647
MC/DC0%0/2
$_[0] >= -2147483648 && $_[0] <= 2147483647
$_[0] >= -2147483648
$_[0] <= 2147483647
Truth table33%1/3
A && B
A= $_[0] >= -2147483648B= $_[0] <= 2147483647
| |||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub _fast_is_num { | ||||||||||||||||||||||||||
|
Subroutine
_fast_is_num: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return if !_fast_is_nonref_defined($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | return looks_like_number($_[0]); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 3810 | ▶ | sub _fast_is_str { | ||||||||||||||||||||||||||
|
Subroutine
_fast_is_str: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 104 | 3810 | return _fast_is_nonref_defined($_[0]); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 40 | ▶ | sub _fast_is_boolish { | ||||||||||||||||||||||||||
|
Subroutine
_fast_is_boolish: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||
| 108 | 40 | ▶ | return 1 if is_bool($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 32 | ▶ | return if !_fast_is_nonref_defined($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 32 | ▶ | return if !looks_like_number($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 32 | ▶ | return $_[0] == 0 || $_[0] == 1; | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[0] == 0 || $_[0] == 1
MC/DC0%0/2
$_[0] == 0 || $_[0] == 1
$_[0] == 0
$_[0] == 1
Truth table66%2/3
A || B
A= $_[0] == 0B= $_[0] == 1
| |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub _builtin_is_valid { | ||||||||||||||||||||||||||
|
Subroutine
_builtin_is_valid: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 115 | 0 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $kind = $self->_builtin_kind or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | return 1 if !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | return _fast_is_int32_signed($item) if $kind eq 'Int'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return _fast_is_num($item) if $kind eq 'Float'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return _fast_is_str($item) if $kind eq 'String'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return _fast_is_boolish($item) if $kind eq 'Boolean'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return _fast_is_str($item) if $kind eq 'ID'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | return; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 3860 | ▶ | sub _builtin_graphql_to_perl { | ||||||||||||||||||||||||||
|
Subroutine
_builtin_graphql_to_perl: called CC=14 SCAR=27.8
| |||||||||||||||||||||||||||||
| 128 | 3860 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 129 | 3860 | ▶ | my $kind = $self->_builtin_kind or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 3860 | ▶ | return $item if !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 3856 | ▶ | if ($kind eq 'Int') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 21 | ▶ | _fast_is_int32_signed($item) or die "Not an Int.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 15 | return $item + 0; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 3835 | ▶ | if ($kind eq 'Float') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | ▶ | _fast_is_num($item) or die "Not a Float.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | 0 | return $item + 0; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 3835 | ▶ | if ($kind eq 'String') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 3783 | ▶ | _fast_is_str($item) or die "Not a String.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 3782 | return $item; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 52 | ▶ | if ($kind eq 'Boolean') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 30 | ▶ | _fast_is_boolish($item) or die "Not a Boolean.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 30 | ▶ | return $item ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 22 | ▶ | if ($kind eq 'ID') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 22 | ▶ | _fast_is_str($item) or die "Not an ID.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 22 | return $item; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 15 | ▶ | sub _builtin_perl_to_graphql { | ||||||||||||||||||||||||||
|
Subroutine
_builtin_perl_to_graphql: called CC=14 SCAR=32.8
| |||||||||||||||||||||||||||||
| 158 | 15 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 159 | 15 | ▶ | my $kind = $self->_builtin_kind or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 15 | ▶ | return $item if !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 15 | ▶ | if ($kind eq 'Int') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | _fast_is_int32_signed($item) or die "Not an Int.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | return $item + 0; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | 15 | ▶ | if ($kind eq 'Float') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | _fast_is_num($item) or die "Not a Float.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | return $item + 0; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 15 | ▶ | if ($kind eq 'String') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 2 | ▶ | _fast_is_str($item) or die "Not a String.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 2 | return $item . ''; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | 13 | ▶ | if ($kind eq 'Boolean') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 10 | ▶ | _fast_is_boolish($item) or die "Not a Boolean.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 10 | ▶ | return $item ? JSON->true : JSON->false; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | 3 | ▶ | if ($kind eq 'ID') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 3 | ▶ | _fast_is_str($item) or die "Not an ID.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 3 | return $item . ''; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | return; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub is_valid { | ||||||||||||||||||||||||||
|
Subroutine
is_valid: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 188 | 0 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $fast = $self->_builtin_kind ? $self->_builtin_is_valid($item) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return $fast if defined $fast; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return 1 if !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 0 | return eval { $self->serialize->($item); 1 }; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 3881 | ▶ | sub graphql_to_perl { | ||||||||||||||||||||||||||
|
Subroutine
graphql_to_perl: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 3881 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 197 | 3881 | ▶ | my $fast = $self->_builtin_kind ? $self->_builtin_graphql_to_perl($item) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 3874 | ▶ | return $fast if defined $fast || !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $fast or not defined $item
MC/DC100%2/2
defined $fast or not defined $item
defined $fast
not defined $item
Truth table100%3/3
A or not(B)
A= defined $fastB= not defined $item
| |||||||||||||||||||||||||||||
| 199 | 21 | return $self->parse_value->($item); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 15 | ▶ | sub perl_to_graphql { | ||||||||||||||||||||||||||
|
Subroutine
perl_to_graphql: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 203 | 15 | my ($self, $item) = @_; | |||||||||||||||||||||||||||
| 204 | 15 | ▶ | my $fast = $self->_builtin_kind ? $self->_builtin_perl_to_graphql($item) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 15 | ▶ | return $fast if defined $fast || !defined $item; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $fast or not defined $item
MC/DC0%0/2
defined $fast or not defined $item
defined $fast
not defined $item
Truth table33%1/3
A or not(B)
A= defined $fastB= not defined $item
| |||||||||||||||||||||||||||||
| 206 | 0 | return $self->serialize->($item); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | our $Int = __PACKAGE__->new( | ||||||||||||||||||||||||||||
| 210 | _builtin_kind => 'Int', | ||||||||||||||||||||||||||||
| 211 | name => 'Int', | ||||||||||||||||||||||||||||
| 212 | description => | ||||||||||||||||||||||||||||
| 213 | 'The `Int` scalar type represents non-fractional signed whole numeric ' . | ||||||||||||||||||||||||||||
| 214 | 'values. Int can represent values between -(2^31) and 2^31 - 1.', | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | serialize => _leave_undef(sub { !_fast_is_int32_signed($_[0]) and die "Not an Int.\n"; $_[0] + 0 }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | parse_value => _leave_undef(sub { !_fast_is_int32_signed($_[0]) and die "Not an Int.\n"; $_[0] + 0 }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | our $Float = __PACKAGE__->new( | ||||||||||||||||||||||||||||
| 220 | _builtin_kind => 'Float', | ||||||||||||||||||||||||||||
| 221 | name => 'Float', | ||||||||||||||||||||||||||||
| 222 | description => | ||||||||||||||||||||||||||||
| 223 | 'The `Float` scalar type represents signed double-precision fractional ' . | ||||||||||||||||||||||||||||
| 224 | 'values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).', | ||||||||||||||||||||||||||||
| 225 | 0 | ▶ | serialize => _leave_undef(sub { !_fast_is_num($_[0]) and die "Not a Float.\n"; $_[0] + 0 }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | ▶ | parse_value => _leave_undef(sub { !_fast_is_num($_[0]) and die "Not a Float.\n"; $_[0] + 0 }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | our $String = __PACKAGE__->new( | ||||||||||||||||||||||||||||
| 230 | _builtin_kind => 'String', | ||||||||||||||||||||||||||||
| 231 | name => 'String', | ||||||||||||||||||||||||||||
| 232 | description => | ||||||||||||||||||||||||||||
| 233 | 'The `String` scalar type represents textual data, represented as UTF-8 ' . | ||||||||||||||||||||||||||||
| 234 | 'character sequences. The String type is most often used by GraphQL to ' . | ||||||||||||||||||||||||||||
| 235 | 'represent free-form human-readable text.', | ||||||||||||||||||||||||||||
| 236 | 0 | ▶ | serialize => _leave_undef(sub { !_fast_is_str($_[0]) and die "Not a String.\n"; $_[0] . '' }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | parse_value => _leave_undef(sub { !_fast_is_str($_[0]) and die "Not a String.\n"; $_[0] }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | ); | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | our $Boolean = __PACKAGE__->new( | ||||||||||||||||||||||||||||
| 241 | _builtin_kind => 'Boolean', | ||||||||||||||||||||||||||||
| 242 | name => 'Boolean', | ||||||||||||||||||||||||||||
| 243 | description => 'The `Boolean` scalar type represents `true` or `false`.', | ||||||||||||||||||||||||||||
| 244 | 0 | ▶ | serialize => _leave_undef(sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | !_fast_is_boolish($_[0]) and die "Not a Boolean.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $_[0] ? JSON->true : JSON->false; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | }), | ||||||||||||||||||||||||||||
| 248 | 0 | ▶ | parse_value => _leave_undef(sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | !_fast_is_boolish($_[0]) and die "Not a Boolean.\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | $_[0] + 0; | |||||||||||||||||||||||||||
| 251 | 62 | }), | |||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | our $ID = __PACKAGE__->new( | ||||||||||||||||||||||||||||
| 255 | _builtin_kind => 'ID', | ||||||||||||||||||||||||||||
| 256 | name => 'ID', | ||||||||||||||||||||||||||||
| 257 | description => | ||||||||||||||||||||||||||||
| 258 | 'The `ID` scalar type represents a unique identifier, often used to ' . | ||||||||||||||||||||||||||||
| 259 | 'refetch an object or as key for a cache. The ID type appears in a JSON ' . | ||||||||||||||||||||||||||||
| 260 | 'response as a String; however, it is not intended to be human-readable. ' . | ||||||||||||||||||||||||||||
| 261 | 'When expected as an input type, any string (such as `"4"`) or integer ' . | ||||||||||||||||||||||||||||
| 262 | '(such as `4`) input value will be accepted as an ID.', | ||||||||||||||||||||||||||||
| 263 | 0 | ▶ | serialize => _leave_undef(sub { !_fast_is_str($_[0]) and die "Not an ID.\n"; $_[0] . '' }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | parse_value => _leave_undef(sub { !_fast_is_str($_[0]) and die "Not an ID.\n"; $_[0] }), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 62 | 1; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | __END__ | ||||||||||||||||||||||||||||