| 1 | package OpenFrame::Cookies; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings::register; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION=3.05; | |||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use OpenFrame::Cookie; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use OpenFrame::Object; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use base qw ( OpenFrame::Object ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 13 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 14 | 3 | $self->cookies( {} ); | |||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | sub cookies { | ||||||||||||||||||||||||||||||
|
Subroutine
cookies: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 18 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 19 | 4 | my $val = shift; | |||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | if (defined( $val )) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 21 | 3 | $self->{cookies} = $val; | |||||||||||||||||||||||||||||||
| 22 | 3 | return $self; | |||||||||||||||||||||||||||||||
| 23 | } else { | ||||||||||||||||||||||||||||||||
| 24 | 1 | return $self->{cookies}; | |||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | sub set { | ||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=6 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 29 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 30 | 2 | my $key = shift; | |||||||||||||||||||||||||||||||
| 31 | 2 | my $val = shift; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | if (defined($key) && !defined($val)) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $key and not defined $val
MC/DC0%0/2
defined $key and not defined $val
defined $key
not defined $val
Truth table33%1/3
A and not(B)
A= defined $keyB= not defined $val
| |||||||||||||||||||||||||||||||||
| 34 | ## chances are we have a Cookie object | ||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($key->isa('OpenFrame::Cookie')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | ## get the name out of the cookie, and we store it | ||||||||||||||||||||||||||||||||
| 37 | 0 | $self->cookies->{ $key->name } = $key; | |||||||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||||||
| 39 | 0 | $self->error("object $key is not an OpenFrame::Cookie"); | |||||||||||||||||||||||||||||||
| 40 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | ▶ | } elsif (defined($key) && defined($val)) { | |||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $key and defined $val
MC/DC0%0/2
defined $key and defined $val
defined $key
defined $val
Truth table33%1/3
A and B
A= defined $keyB= defined $val
| |||||||||||||||||||||||||||||||||
| 43 | ## right, we have a key value pair that we need to turn | ||||||||||||||||||||||||||||||||
| 44 | ## into an OpenFrame::Cookie object | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 2 | my $cookie = OpenFrame::Cookie->new(); | |||||||||||||||||||||||||||||||
| 47 | 2 | $cookie->name( $key ); | |||||||||||||||||||||||||||||||
| 48 | 0 | $cookie->value( [ $val ] ); | |||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | ## call this method again with the cookie as the parameter | ||||||||||||||||||||||||||||||||
| 51 | 0 | $self->set( $cookie ); | |||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||
| 54 | 0 | $self->error("usage: ->set( <COOKIE || KEY, VALUE> )"); | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 61 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (defined( $key )) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 0 | return $self->cookies->{ $key }; | |||||||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||||||
| 65 | 0 | $self->error("no key specified"); | |||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 71 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if (defined( $key )) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | 0 | delete $self->{ cookies }->{ $key }; | |||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||
| 75 | 0 | $self->error("no key specified"); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub get_all { | ||||||||||||||||||||||||||||||
|
Subroutine
get_all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 80 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 81 | 1 | return %{$self->cookies}; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 3 | 1; | |||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||||||