blib/lib/WebDyne/Cloudflare/KV.pm

filter: Statementstmt 97.2% 139 / 143 Branchbran 73.5% 50 / 68 Conditioncond 51.8% 43 / 83 MC/DCmcdc 21.4% 9 / 42 Subroutinesub 100% 29 / 29 Podpod 0.0% 0 / 15 totaltotal 71.0% 270 / 380 CC 63 SCAR 22.1
CC
63
Cov
79%
new
21.5
decode_bytes
13.1
get_with_metadata
12.1
CRAP 9.2
« blib/lib/WebDyne/Cloudflare/D1.pm ↑ Summary blib/lib/WebDyne/Cloudflare/Hyperdrive.pm »
1 package WebDyne::Cloudflare::KV;
2  
3 3 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Encode qw(decode FB_CROAK);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use WebDyne::Cloudflare ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use MIME::Base64 qw(decode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use WebDyne::Cloudflare::KV::Blob;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use WebDyne::Cloudflare::KV::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 our $VERSION='0.001';
17 3 our $HOST_CALL;
18  
19 3 ▶use constant EXTENSION_NAME => 'webdyne.cloudflare.kv';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use constant PROTOCOL_VERSION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 my $json_or=JSON::PP->new()->canonical()->allow_nonref();
23  
24 8 ▶sub new {
Subroutine new: called CC=16 SCAR=30.7
Pod undocumented
25 8 my ($class, %opt)=@_;
26 8 my $scope_hr=$opt{'scope'};
27 8 ▶ die "WebDyne::Cloudflare::KV requires a PAGI scope hash\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $scope_hr eq "HASH" 0 8 8
28 unless ref($scope_hr) eq 'HASH';
29 my $extension_hr=(ref($scope_hr->{'extensions'}) eq 'HASH')
30 8 ▶ ? $scope_hr->{'extensions'}{EXTENSION_NAME()}
Branch: 1 branch
BranchTrueFalseTotal
ref $scope_hr->{'extensions'} eq 'HASH' ? : 6 2 8
31 : undef;
32 8 ▶ die "PAGI scope has no " . EXTENSION_NAME() . " capability\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $extension_hr eq "HASH" 3 5 8
33 unless ref($extension_hr) eq 'HASH';
34 die "Unsupported KV capability protocol\n"
35 unless (defined($extension_hr->{'version'})
36 &&!ref($extension_hr->{'version'})
37 5 ▶ &&($extension_hr->{'version'} eq PROTOCOL_VERSION()));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extension_hr->{"version"} and not ref $extension_hr->{"version"} and $extension_hr->{"version"} eq 1 1 4 5
Condition50%3/6
defined $extension_hr->{"version"} and not ref $extension_hr->{"version"} and $extension_hr->{"version"} eq 1
!ll&&!rl&&r
014
defined $extension_hr->{"version"} and not ref $extension_hr->{"version"}
!ll&&!rl&&r
005
MC/DC33%1/3
defined $extension_hr->{"version"} and not ref $extension_hr->{"version"} and $extension_hr->{"version"} eq 1
defined $extension_hr->{"version"} not ref $extension_hr->{"version"} $extension_hr->{"version"} eq 1
Truth table50%2/4
A and not(B) and C
A= defined $extension_hr->{"version"}B= not ref $extension_hr->{"version"}C= $extension_hr->{"version"} eq 1
ABCresult
0XX0
10X0
1100
1111
38 die "Invalid KV capability token\n"
39 unless (defined($extension_hr->{'capability'})
40 &&!ref($extension_hr->{'capability'})
41 4 ▶ &&length($extension_hr->{'capability'}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extension_hr->{"capability"} and not ref $extension_hr->{"capability"} and length $extension_hr->{"capability"} 0 4 4
Condition33%2/6
defined $extension_hr->{"capability"} and not ref $extension_hr->{"capability"} and length $extension_hr->{"capability"}
!ll&&!rl&&r
004
defined $extension_hr->{"capability"} and not ref $extension_hr->{"capability"}
!ll&&!rl&&r
004
MC/DC0%0/3
defined $extension_hr->{"capability"} and not ref $extension_hr->{"capability"} and length $extension_hr->{"capability"}
defined $extension_hr->{"capability"} not ref $extension_hr->{"capability"} length $extension_hr->{"capability"}
Truth table25%1/4
A and not(B) and C
A= defined $extension_hr->{"capability"}B= not ref $extension_hr->{"capability"}C= length $extension_hr->{"capability"}
ABCresult
0XX0
10X0
1100
1111
42  
43 4 ▶ my $binding=(defined($opt{'binding'}) ? $opt{'binding'} : 'KV');
Branch: 1 branch
BranchTrueFalseTotal
defined $opt{'binding'} ? : 3 1 4
44 4 ▶ die "Invalid KV binding name '$binding'\n"
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $binding and $binding =~ /\A[A-Z_][A-Z0-9_]*\z/u 0 4 4
Condition33%1/3
not ref $binding and $binding =~ /\A[A-Z_][A-Z0-9_]*\z/u
!ll&&!rl&&r
004
MC/DC0%0/2
not ref $binding and $binding =~ /\A[A-Z_][A-Z0-9_]*\z/u
not ref $binding $binding =~ /\A[A-Z_][A-Z0-9_]*\z/u
Truth table33%1/3
not(A) and B
A= not ref $bindingB= $binding =~ /\A[A-Z_][A-Z0-9_]*\z/u
ABresult
0X0
100
111
45 unless (!ref($binding)&&($binding=~/\A[A-Z_][A-Z0-9_]*\z/));
46 4 my $bindings_ar=$extension_hr->{'bindings'};
47 4 ▶ die "Invalid KV capability binding list\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $bindings_ar eq "ARRAY" 1 3 4
48 unless (ref($bindings_ar) eq 'ARRAY');
49 3 ▶ my %binding=map { $_ => 1 } grep { defined($_)&&!ref($_) } @{$bindings_ar};
Condition33%1/3
defined $_ && !ref($_)
!ll&&!rl&&r
003
MC/DC0%0/2
defined $_ && !ref($_)
defined $_ !ref($_)
Truth table33%1/3
A && not(B)
A= defined $_B= !ref($_)
ABresult
0X0
100
111
50 die "KV binding '$binding' is not available to this request\n"
51 3 ▶ unless $binding{$binding};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding{$binding} 0 3 3
52  
53 my $self=bless({
54 binding => $binding,
55 3 capability => $extension_hr->{'capability'},
56 }, $class);
57 3 return $self;
58 }
59  
60  
61 1 ▶sub binding { return shift()->{'binding'}; }
Subroutine binding: called CC=1 SCAR=0.0
Pod undocumented
62  
63  
64 23 ▶sub blob {
Subroutine blob: called CC=7 SCAR=19.5
Pod undocumented
65 # Accept function, class and object calls without discarding payload bytes.
66 #
67 23 ▶ shift() if ((@_>1)&&(defined($_[0])
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and (defined $_[0] and builtin::blessed($_[0]) || !ref($_[0]) && $_[0] eq __PACKAGE__) 15 8 23
Condition83%10/12
@_ > 1 and (defined $_[0] and builtin::blessed($_[0]) || !ref($_[0]) && $_[0] eq __PACKAGE__)
!ll&&!rl&&r
7115
defined $_[0] and builtin::blessed($_[0]) || !ref($_[0]) && $_[0] eq __PACKAGE__
!ll&&!rl&&r
0115
builtin::blessed($_[0]) or not ref $_[0] and $_[0] eq __PACKAGE__
l!l&&r!l&&!r
4111
not ref $_[0] and $_[0] eq __PACKAGE__
!ll&&!rl&&r
0111
MC/DC60%3/5
@_ > 1 and (defined $_[0] and builtin::blessed($_[0]) || !ref($_[0]) && $_[0] eq __PACKAGE__)
@_ > 1 defined $_[0] builtin::blessed($_[0]) not ref $_[0] $_[0] eq __PACKAGE__
Truth table66%4/6
A and B and C or not(D) and E
A= @_ > 1B= defined $_[0]C= builtin::blessed($_[0])D= not ref $_[0]E= $_[0] eq __PACKAGE__
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
68 &&(blessed($_[0])||(!ref($_[0])&&($_[0] eq __PACKAGE__)))));
69 23 ▶ die "KV blob requires exactly one byte string\n" unless (@_==1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 1 22 23
70 22 return WebDyne::Cloudflare::KV::Blob->new($_[0]);
71 }
72  
73  
74 14 ▶sub key {
Subroutine key: called CC=6 SCAR=24.3
Pod undocumented
75 14 my ($key)=@_;
76 14 ▶ die "KV key must be a non-empty scalar other than . or ..\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key and not ref $key and length $key and $key ne "." and $key ne ".." 0 14 14
Condition33%4/12
defined $key and not ref $key and length $key and $key ne "." and $key ne ".."
!ll&&!rl&&r
0014
defined $key and not ref $key and length $key and $key ne "."
!ll&&!rl&&r
0014
defined $key and not ref $key and length $key
!ll&&!rl&&r
0014
defined $key and not ref $key
!ll&&!rl&&r
0014
MC/DC0%0/5
defined $key and not ref $key and length $key and $key ne "." and $key ne ".."
defined $key not ref $key length $key $key ne "." $key ne ".."
Truth table16%1/6
A and not(B) and C and D and E
A= defined $keyB= not ref $keyC= length $keyD= $key ne "."E= $key ne ".."
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
77 unless (defined($key)&&!ref($key)&&length($key)
78 &&($key ne '.')&&($key ne '..'));
79 14 return $key;
80 }
81  
82  
83 17 ▶sub known_options {
Subroutine known_options: called CC=2 SCAR=6.9
Pod undocumented
84 17 my ($operation, $allowed_ar, %opt)=@_;
85 17 my %allowed=map { $_ => 1 } @{$allowed_ar};
86 17 my @unknown=sort grep { !$allowed{$_} } keys %opt;
87 17 ▶ die "Unknown KV $operation option: $unknown[0]\n" if @unknown;
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 1 16 17
88 16 return %opt;
89 }
90  
91  
92 6 ▶sub encode_text {
Subroutine encode_text: called CC=5 SCAR=16.1
Pod undocumented
93 6 my ($value_ref)=@_;
94 6 ▶ die "KV value must be a scalar or KV blob\n" if (!defined($value_ref)||ref($value_ref));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value_ref or ref $value_ref 1 5 6
Condition66%2/3
not defined $value_ref or ref $value_ref
l!l&&r!l&&!r
015
MC/DC50%1/2
not defined $value_ref or ref $value_ref
not defined $value_ref ref $value_ref
Truth table66%2/3
not(A) or B
A= not defined $value_refB= ref $value_ref
ABresult
1X1
011
000
95 5 ▶ return decode('UTF-8', $value_ref, FB_CROAK)
Branch: 1 branch
BranchTrueFalseTotal
if not utf8::is_utf8($value_ref) and $value_ref =~ /[\x80-\xff]/u 1 4 5
Condition100%3/3
not utf8::is_utf8($value_ref) and $value_ref =~ /[\x80-\xff]/u
!ll&&!rl&&r
131
MC/DC100%2/2
not utf8::is_utf8($value_ref) and $value_ref =~ /[\x80-\xff]/u
not utf8::is_utf8($value_ref) $value_ref =~ /[\x80-\xff]/u
Truth table100%3/3
not(A) and B
A= not utf8::is_utf8($value_ref)B= $value_ref =~ /[\x80-\xff]/u
ABresult
0X0
100
111
96 if (!utf8::is_utf8($value_ref)&&($value_ref=~/[\x80-\xff]/));
97 4 return "$value_ref";
98 }
99  
100  
101 1 ▶sub decode_bytes {
Subroutine decode_bytes: called CC=7 SCAR=25.7
Pod undocumented
102 1 my ($value_ref)=@_;
103 1 ▶ return undef unless defined($value_ref);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value_ref 0 1 1
104 die "KV host returned an invalid byte value\n"
105 unless ((ref($value_ref) eq 'HASH')
106 &&defined($value_ref->{'type'})&&($value_ref->{'type'} eq 'bytes')
107 1 ▶ &&defined($value_ref->{'base64'})&&!ref($value_ref->{'base64'}));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value_ref eq "HASH" and defined $value_ref->{"type"} and $value_ref->{"type"} eq "bytes" and defined $value_ref->{"base64"} and not ref $value_ref->{"base64"} 0 1 1
Condition33%4/12
ref $value_ref eq "HASH" and defined $value_ref->{"type"} and $value_ref->{"type"} eq "bytes" and defined $value_ref->{"base64"} and not ref $value_ref->{"base64"}
!ll&&!rl&&r
001
ref $value_ref eq "HASH" and defined $value_ref->{"type"} and $value_ref->{"type"} eq "bytes" and defined $value_ref->{"base64"}
!ll&&!rl&&r
001
ref $value_ref eq "HASH" and defined $value_ref->{"type"} and $value_ref->{"type"} eq "bytes"
!ll&&!rl&&r
001
ref $value_ref eq "HASH" and defined $value_ref->{"type"}
!ll&&!rl&&r
001
MC/DC0%0/5
ref $value_ref eq "HASH" and defined $value_ref->{"type"} and $value_ref->{"type"} eq "bytes" and defined $value_ref->{"base64"} and not ref $value_ref->{"base64"}
ref $value_ref eq "HASH" defined $value_ref->{"type"} $value_ref->{"type"} eq "bytes" defined $value_ref->{"base64"} not ref $value_ref->{"base64"}
Truth table16%1/6
A and B and C and D and not(E)
A= ref $value_ref eq "HASH"B= defined $value_ref->{"type"}C= $value_ref->{"type"} eq "bytes"D= defined $value_ref->{"base64"}E= not ref $value_ref->{"base64"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
108 1 return decode_base64($value_ref->{'base64'});
109 }
110  
111  
112 6 ▶async sub get {
Subroutine get: called CC=7 SCAR=19.7
Pod undocumented
113 6 my ($self, $key, %opt)=@_;
114 6 %opt=known_options('get', [qw(type cache_ttl)], %opt);
115 6 ▶ my $type=(defined($opt{'type'}) ? $opt{'type'} : 'text');
Branch: 1 branch
BranchTrueFalseTotal
defined $opt{'type'} ? : 2 4 6
116 6 ▶ die "KV get type must be text, json, or bytes\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "text" or $type eq "json" or $type eq "bytes" 0 6 6
Condition83%5/6
$type eq "text" or $type eq "json" or $type eq "bytes"
l!l&&r!l&&!r
510
$type eq "text" or $type eq "json"
l!l&&r!l&&!r
411
MC/DC0%0/3
$type eq "text" or $type eq "json" or $type eq "bytes"
$type eq "text" $type eq "json" $type eq "bytes"
Truth table75%3/4
A or B or C
A= $type eq "text"B= $type eq "json"C= $type eq "bytes"
ABCresult
1XX1
01X1
0011
0000
117 unless (($type eq 'text')||($type eq 'json')||($type eq 'bytes'));
118 my $result_ref=await $self->execute(
119 operation => 'get',
120 key => key($key),
121 type => $type,
122 6 ▶ (defined($opt{'cache_ttl'}) ? (cache_ttl => $opt{'cache_ttl'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt{'cache_ttl'} ? : 0 6 6
123 );
124 3 ▶ return $type eq 'bytes' ? decode_bytes($result_ref) : $result_ref;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'bytes' ? : 1 2 3
125 3 }
126  
127  
128 1 ▶async sub get_with_metadata {
Subroutine get_with_metadata: called CC=8 SCAR=24.9
Pod undocumented
129 1 my ($self, $key, %opt)=@_;
130 1 %opt=known_options('get_with_metadata', [qw(type cache_ttl)], %opt);
131 1 ▶ my $type=(defined($opt{'type'}) ? $opt{'type'} : 'text');
Branch: 1 branch
BranchTrueFalseTotal
defined $opt{'type'} ? : 0 1 1
132 1 ▶ die "KV get type must be text, json, or bytes\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "text" or $type eq "json" or $type eq "bytes" 0 1 1
Condition33%2/6
$type eq "text" or $type eq "json" or $type eq "bytes"
l!l&&r!l&&!r
100
$type eq "text" or $type eq "json"
l!l&&r!l&&!r
100
MC/DC0%0/3
$type eq "text" or $type eq "json" or $type eq "bytes"
$type eq "text" $type eq "json" $type eq "bytes"
Truth table25%1/4
A or B or C
A= $type eq "text"B= $type eq "json"C= $type eq "bytes"
ABCresult
1XX1
01X1
0011
0000
133 unless (($type eq 'text')||($type eq 'json')||($type eq 'bytes'));
134 my $result_ref=await $self->execute(
135 operation => 'get_with_metadata',
136 key => key($key),
137 type => $type,
138 1 ▶ (defined($opt{'cache_ttl'}) ? (cache_ttl => $opt{'cache_ttl'}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $opt{'cache_ttl'} ? : 0 1 1
139 );
140 1 ▶ $result_ref->{'value'}=decode_bytes($result_ref->{'value'})
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "bytes" and ref $result_ref eq "HASH" 0 1 1
Condition33%1/3
$type eq "bytes" and ref $result_ref eq "HASH"
!ll&&!rl&&r
100
MC/DC0%0/2
$type eq "bytes" and ref $result_ref eq "HASH"
$type eq "bytes" ref $result_ref eq "HASH"
Truth table33%1/3
A and B
A= $type eq "bytes"B= ref $result_ref eq "HASH"
ABresult
0X0
100
111
141 if (($type eq 'bytes')&&(ref($result_ref) eq 'HASH'));
142 1 return $result_ref;
143 3 }
144  
145  
146 7 ▶async sub put {
Subroutine put: called CC=6 SCAR=18.0
Pod undocumented
147 7 my ($self, $key, $value_ref, %opt)=@_;
148 7 %opt=known_options('put', [qw(expiration expiration_ttl metadata)], %opt);
149 7 ▶ my $encoded_ref=(blessed($value_ref)&&$value_ref->isa('WebDyne::Cloudflare::KV::Blob'))
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($value_ref) && $value_ref->isa('WebDyne::Cloudflare::KV::Blob') ? : 1 6 7
Condition66%2/3
builtin::blessed($value_ref) and $value_ref->isa("WebDyne::Cloudflare::KV::Blob")
!ll&&!rl&&r
601
MC/DC50%1/2
builtin::blessed($value_ref) and $value_ref->isa("WebDyne::Cloudflare::KV::Blob")
builtin::blessed($value_ref) $value_ref->isa("WebDyne::Cloudflare::KV::Blob")
Truth table66%2/3
A and B
A= builtin::blessed($value_ref)B= $value_ref->isa("WebDyne::Cloudflare::KV::Blob")
ABresult
0X0
100
111
150 ? $value_ref->wire_value()
151 : encode_text($value_ref);
152 return await $self->execute(
153 operation => 'put',
154 key => key($key),
155 value => $encoded_ref,
156 (defined($opt{'expiration'}) ? (expiration => $opt{'expiration'}) : ()),
157 (defined($opt{'expiration_ttl'}) ? (expiration_ttl => $opt{'expiration_ttl'}) : ()),
158 6 ▶ (exists($opt{'metadata'}) ? (metadata => $opt{'metadata'}) : ()),
Branch: 3 branches
BranchTrueFalseTotal
defined $opt{'expiration'} ? : 0 6 6
defined $opt{'expiration_ttl'} ? : 1 5 6
exists $opt{'metadata'} ? : 2 4 6
159 );
160 3 }
161  
162  
163 2 ▶async sub put_json {
Subroutine put_json: called CC=1 SCAR=0.0
Pod undocumented
164 2 my ($self, $key, $value_ref, %opt)=@_;
165 2 return await $self->put($key, $json_or->encode(WebDyne::Cloudflare::json_value($value_ref)), %opt);
166 3 }
167  
168  
169 1 ▶async sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod undocumented
170 1 my ($self, $key)=@_;
171 1 return await $self->execute(operation => 'delete', key => key($key));
172 3 }
173  
174  
175 3 ▶async sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod undocumented
176 3 my ($self, %opt)=@_;
177 3 %opt=known_options('list', [qw(prefix cursor limit)], %opt);
178 2 return await $self->execute(operation => 'list', %opt);
179 3 }
180  
181  
182 15 ▶sub call_host {
Subroutine call_host: called CC=3 SCAR=14.8
Pod undocumented
183 15 my ($wire)=@_;
184 15 ▶ return $HOST_CALL->($wire) if $HOST_CALL;
Branch: 1 branch
BranchTrueFalseTotal
if $WebDyne::Cloudflare::KV::HOST_CALL 15 0 15
185 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
186 0 my $host_call_cr=*{'WebDyne::Cloudflare::KV::Host::call'}{'CODE'};
187 0 ▶ die "KV host adapter is not registered in this runtime\n" unless $host_call_cr;
Branch: 1 branch
BranchTrueFalseTotal
unless $host_call_cr 0 0 0
188 0 return $host_call_cr->($wire);
189 }
190  
191  
192 16 ▶async sub execute {
Subroutine execute: called CC=6 SCAR=18.0
Pod undocumented
193 16 my ($self, %request)=@_;
194 my $wire_hr={
195 version => PROTOCOL_VERSION,
196 capability => $self->{'capability'},
197 16 binding => $self->{'binding'},
198 %request,
199 };
200 16 my $response_wire=call_host($json_or->encode(WebDyne::Cloudflare::json_value($wire_hr)));
201 15 my $response_hr=eval { $json_or->decode($response_wire) };
202 15 ▶ if ((ref($response_hr) ne 'HASH')||!exists($response_hr->{'ok'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $response_hr ne "HASH" or not exists $response_hr->{"ok"}) 1 14 15
Condition66%2/3
ref $response_hr ne "HASH" or not exists $response_hr->{"ok"}
l!l&&r!l&&!r
0114
MC/DC50%1/2
ref $response_hr ne "HASH" or not exists $response_hr->{"ok"}
ref $response_hr ne "HASH" not exists $response_hr->{"ok"}
Truth table66%2/3
A or not(B)
A= ref $response_hr ne "HASH"B= not exists $response_hr->{"ok"}
ABresult
1X1
011
000
203 1 ▶ my $detail=$@||'host returned an invalid response';
Condition50%1/2
$@ || 'host returned an invalid response'
l!l
01
MC/DC0%0/1
$@ || 'host returned an invalid response'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
204 1 die WebDyne::Cloudflare::KV::Error->new(name => 'KV_PROTOCOL_ERROR', message => $detail);
205 }
206 14 ▶ unless ($response_hr->{'ok'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response_hr->{"ok"}) 1 13 14
207 1 ▶ my $error_hr=ref($response_hr->{'error'}) eq 'HASH' ? $response_hr->{'error'} : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $response_hr->{'error'} eq 'HASH' ? : 1 0 1
208 1 die WebDyne::Cloudflare::KV::Error->new(%{$error_hr});
209 }
210 13 return $response_hr->{'result'};
211 3 }
212  
213 3 1;
« blib/lib/WebDyne/Cloudflare/D1.pm ↑ Summary blib/lib/WebDyne/Cloudflare/Hyperdrive.pm »