SDK/Core/Headers.pm

filter: Statementstmt 100% 32 / 32 Branchbran 90.0% 9 / 10 Conditioncond 50.0% 4 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 87.6% 57 / 65 CC 11 SCAR 15.5
CC
11
Cov
90%
set
8.3
__ANON__
3.1
get
2.0
CRAP 4.7
« SDK/AppConfiguration/SyncToken.pm ↑ Summary SDK/Storage/Blobs/Serializer.pm »
1 21 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 21 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 21 class Azure::SDK::Core::Headers {
6 21 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 21 field $headers :param = {};
9 21 field %values;
10
11 388 ▶ ADJUST {
Subroutine __ANON__: called CC=3 SCAR=11.2
12 388 ▶ croak 'Azure::SDK::Core::Headers requires a hashref'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $headers eq "HASH" 0 388 388
13 unless ref $headers eq 'HASH';
14
15 388 for my $name ( keys $headers->%* ) {
16 199 $self->set($name, $headers->{$name});
17 }
18 }
19
20 1562 ▶ method get ($name) {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
21 1562 my $stored = $values{ lc $name };
22 1562 ▶ return undef unless defined $stored;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $stored 1041 521 1562
23 521 return join ', ', $stored->@*;
24 }
25
26 827 ▶ method set ($name, $value) {
Subroutine set: called CC=8 SCAR=21.2
Pod documented
27 827 ▶ croak 'Invalid header name'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name and $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u 4 823 827
Condition50%3/6
defined $name and not ref $name and $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
!ll&&!rl&&r
04823
defined $name and not ref $name
!ll&&!rl&&r
00827
MC/DC33%1/3
defined $name and not ref $name and $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
defined $name not ref $name $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
Truth table50%2/4
A and not(B) and C
A= defined $nameB= not ref $nameC= $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
ABCresult
0XX0
10X0
1100
1111
28 unless defined $name
29 && !ref $name
30 && $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/;
31
32 823 ▶ my @incoming = ref $value eq 'ARRAY' ? $value->@* : ($value);
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 2 821 823
33 823 my @normalized;
34 823 for my $header_value (@incoming) {
35 825 ▶ $header_value //= '';
Condition50%1/2
$header_value //= ""
l!l
8250
MC/DC0%0/1
$header_value //= ""
$header_value
Truth table50%1/2
A
A= $header_value
Aresult
11
00
36 825 ▶ croak "Invalid characters in $name header"
Branch: 1 branch
BranchTrueFalseTotal
if $header_value =~ /[\x00-\x08\x0a-\x1f\x7f]/u 5 820 825
37 if $header_value =~ /[\x00-\x08\x0a-\x1f\x7f]/;
38 820 push @normalized, "$header_value";
39 }
40
41 818 $values{ lc $name } = \@normalized;
42 818 return $self;
43 }
44
45 72 ▶ method as_hashref () {
Subroutine as_hashref: called CC=1 SCAR=0.0
Pod documented
46 72 return { map { $_ => $self->get($_) } keys %values };
47 }
48 }
49
50 21 1;
51
52 __END__
« SDK/AppConfiguration/SyncToken.pm ↑ Summary SDK/Storage/Blobs/Serializer.pm »