Mojo/Cookie/Request.pm

filter: Statementstmt 100% 20 / 20 Branchbran 100% 8 / 8 Conditioncond 87.5% 7 / 8 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 95.6% 44 / 46 CC 9 SCAR 14.7
CC
9
Cov
97%
parse
5.0
to_string
5.0
BEGIN
1.0
CRAP 4.3
« Mojo/UserAgent/Server.pm ↑ Summary Mojo/Loader.pm »
1 package Mojo::Cookie::Request;
2 29 ▶use Mojo::Base 'Mojo::Cookie';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 29 ▶use Mojo::Util qw(quote split_header);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 58 ▶sub parse {
Subroutine parse: called CC=5 SCAR=16.1
Pod documented
7 58 my ($self, $str) = @_;
8  
9 58 my @cookies;
10 58 ▶ my @pairs = map {@$_} @{split_header $str // ''};
Condition100%2/2
$str // ""
l!l
3424
MC/DC100%1/1
$str // ""
$str
Truth table100%2/2
A
A= $str
Aresult
11
00
11 58 ▶ while (my ($name, $value) = splice @pairs, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@pairs, 0, 2)) 72 58 130
12 72 ▶ next if $name =~ /^\$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^\$/u 23 49 72
13 49 ▶ push @cookies, $self->new(name => $name, value => $value // '');
Condition50%1/2
$value // ""
l!l
490
MC/DC0%0/1
$value // ""
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
14 }
15  
16 58 return \@cookies;
17 }
18  
19 31 ▶sub to_string {
Subroutine to_string: called CC=5 SCAR=16.1
Pod documented
20 31 my $self = shift;
21 31 ▶ return '' unless length(my $name = $self->name // '');
Branch: 1 branch
BranchTrueFalseTotal
unless length(my $name = $self->name // "") 1 30 31
Condition100%2/2
$self->name // ""
l!l
301
MC/DC100%1/1
$self->name // ""
$self->name
Truth table100%2/2
A
A= $self->name
Aresult
11
00
22 30 ▶ my $value = $self->value // '';
Condition100%2/2
$self->value // ""
l!l
291
MC/DC100%1/1
$self->value // ""
$self->value
Truth table100%2/2
A
A= $self->value
Aresult
11
00
23 30 ▶ return join '=', $name, $value =~ /[,;" ]/ ? quote $value : $value;
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /[,;" ]/u ? : 5 25 30
24 }
25  
26 29 1;
27  
28 =encoding utf8
29  
30 =head1 NAME
31  
32 Mojo::Cookie::Request - HTTP request cookie
33  
34 =head1 SYNOPSIS
35  
36 use Mojo::Cookie::Request;
37  
38 my $cookie = Mojo::Cookie::Request->new;
39 $cookie->name('foo');
40 $cookie->value('bar');
41 say "$cookie";
42  
43 =head1 DESCRIPTION
44  
45 L<Mojo::Cookie::Request> is a container for HTTP request cookies, based on L<RFC
46 6265|https://tools.ietf.org/html/rfc6265>.
47  
48 =head1 ATTRIBUTES
49  
50 L<Mojo::Cookie::Request> inherits all attributes from L<Mojo::Cookie>.
51  
52 =head1 METHODS
53  
54 L<Mojo::Cookie::Request> inherits all methods from L<Mojo::Cookie> and implements the following new ones.
55  
56 =head2 parse
57  
58 my $cookies = Mojo::Cookie::Request->parse('f=b; g=a');
59  
60 Parse cookies.
61  
62 =head2 to_string
63  
64 my $str = $cookie->to_string;
65  
66 Render cookie.
67  
68 =head1 SEE ALSO
69  
70 L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
71  
72 =cut
« Mojo/UserAgent/Server.pm ↑ Summary Mojo/Loader.pm »