blib/lib/GraphQL/Houtou/Role/HashMappable.pm

filter: Statementstmt 52.1% 12 / 23 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 43.2% 16 / 37 CC 5 SCAR 28.4
CC
5
Cov
39%
hashmap
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 17.1
« blib/lib/GraphQL/Houtou/Federation.pm ↑ Summary blib/lib/GraphQL/Houtou/PSGI.pm »
1 package GraphQL::Houtou::Role::HashMappable;
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 Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Utility helpers for hash-shaped GraphQL values and field maps.
10  
11 0 ▶sub hashmap {
Subroutine hashmap: not called CC=5 SCAR=34.0
Pod undocumented
12 0 my ($self, $item, $source, $code) = @_;
13 0 ▶ return $item if !defined $item;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item 0 0 0
14  
15 my @errors = map qq{In field "$_": Unknown field.\n},
16 0 grep { !exists $source->{$_} } sort keys %$item;
17 my %newvalue = map {
18 0 my @pair = eval { ($_ => scalar $code->($_, $item->{$_})) };
19 0 ▶ push @errors, qq{In field "$_": $@} if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
20 0 ▶ exists $item->{$_} ? @pair : ();
Branch: 1 branch
BranchTrueFalseTotal
exists $item->{$_} ? : 0 0 0
21 } sort keys %$source;
22  
23 0 ▶ die @errors if @errors;
Branch: 1 branch
BranchTrueFalseTotal
if @errors 0 0 0
24 0 return \%newvalue;
25 }
26  
27 62 1;
« blib/lib/GraphQL/Houtou/Federation.pm ↑ Summary blib/lib/GraphQL/Houtou/PSGI.pm »