| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%3/6
defined $name and not ref $name and $name =~ /\A[!#$%&'*+\-.^_`|~0-9A-Za-z]+\z/u
defined $name and not ref $name
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 823 | my @normalized; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 823 | for my $header_value (@incoming) { | |||||||||||||||||||||||||||||||||||||||||
| 35 | 825 | ▶ | $header_value //= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$header_value //= ""
MC/DC0%0/1
$header_value //= ""
$header_value
Truth table50%1/2
A
A= $header_value
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 825 | ▶ | croak "Invalid characters in $name header" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||