MojoX/Session/Transport/Cookie.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 96.1% 50 / 52 CC 5 SCAR 8.3
CC
5
Cov
95%
get
4.1
set
2.0
BEGIN
1.0
CRAP 2.3
« MojoX/Session/Store/Dbic.pm ↑ Summary Mojolicious/Plugin/Session.pm »
1 package MojoX::Session::Transport::Cookie;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use base 'MojoX::Session::Transport';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 ▶use Mojo::Cookie::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Mojo::Cookie::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 15 __PACKAGE__->attr(name => 'sid');
12 15 __PACKAGE__->attr(path => '/');
13 15 __PACKAGE__->attr([qw/domain httponly secure/]);
14  
15 2 ▶sub get {
Subroutine get: called CC=4 SCAR=14.0
Pod documented
16 2 my ($self) = @_;
17  
18 2 my $cookies = $self->tx->req->cookies;
19 2 ▶ return unless $cookies;
Branch: 1 branch
BranchTrueFalseTotal
unless $cookies 0 2 2
20  
21 2 my $sid;
22 2 foreach my $cookie (@$cookies) {
23 3 ▶ if ($cookie->name eq $self->name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cookie->name eq $self->name) 2 1 3
24 2 return $cookie->value;
25 }
26 }
27  
28 0 return;
29 }
30  
31 18 ▶sub set {
Subroutine set: called CC=2 SCAR=6.9
Pod documented
32 18 my ($self, $sid, $expires) = @_;
33  
34 18 my $cookie = Mojo::Cookie::Response->new;
35  
36 18 $cookie->name($self->name)->value($sid);
37 18 $cookie->path($self->path);
38 18 $cookie->domain($self->domain);
39 18 $cookie->httponly($self->httponly);
40 18 $cookie->secure($self->secure);
41 18 $cookie->expires($expires);
42  
43 18 ▶ $cookie->max_age(0) if $expires < time;
Branch: 1 branch
BranchTrueFalseTotal
if $expires < time 2 16 18
44  
45 18 $self->tx->res->cookies($cookie);
46 }
47  
48 15 1;
49 __END__
« MojoX/Session/Store/Dbic.pm ↑ Summary Mojolicious/Plugin/Session.pm »