Pure/Save.pm

filter: Statementstmt 94.3% 50 / 53 Branchbran 70.0% 7 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 82.4% 75 / 91 SCAR 24.4
CC
11
Cov
85%
load
5.8
save
5.3
new
3.0
CRAP 11.4
« Pure.pm ↑ Summary
1 package CGI::Pure::Save;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Constants.
13 5 Readonly::Scalar my $EMPTY_STR => q{};
14  
15 5 our $VERSION = 0.08;
16  
17 # Constructor.
18 sub new {
19 4 ▶ my ($class, @params) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
20 4 my $self = bless {}, $class;
21  
22 # CGI::Pure object.
23 4 $self->{'cgi_pure'} = $EMPTY_STR;
24  
25 # Process params.
26 4 set_params($self, @params);
27  
28 # CGI::Pure object not exist.
29 4 ▶ if (! $self->{'cgi_pure'} || ! $self->{'cgi_pure'}->isa('CGI::Pure')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"cgi_pure"} and $self->{"cgi_pure"}->isa("CGI::Pure")) 1 3 4
Condition66%2/3
$self->{"cgi_pure"} and $self->{"cgi_pure"}->isa("CGI::Pure")
!ll&&!rl&&r
103
MC/DC50%1/2
$self->{"cgi_pure"} and $self->{"cgi_pure"}->isa("CGI::Pure")
$self->{"cgi_pure"} $self->{"cgi_pure"}->isa("CGI::Pure")
Truth table66%2/3
A and B
A= $self->{"cgi_pure"}B= $self->{"cgi_pure"}->isa("CGI::Pure")
ABresult
0X0
100
111
30 1 err 'CGI::Pure object doesn\'t define.';
31 }
32  
33 # Object.
34 3 return $self;
35 }
36  
37 # Load parameters from file.
38 sub load {
39 1 ▶ my ($self, $fh) = @_;
Subroutine load: called CC=5 SCAR=17.6
Pod documented
40 1 ▶ if (! $fh || ! fileno $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh and fileno $fh) 0 1 1
Condition33%1/3
$fh and fileno $fh
!ll&&!rl&&r
001
MC/DC0%0/2
$fh and fileno $fh
$fh fileno $fh
Truth table33%1/3
A and B
A= $fhB= fileno $fh
ABresult
0X0
100
111
41 0 err 'Invalid filehandle.';
42 }
43 1 local $INPUT_RECORD_SEPARATOR = "\n";
44 1 ▶ while (my $pair = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $pair = readline $fh)) 3 0 3
45 3 chomp $pair;
46 3 ▶ if ($pair eq q{=}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pair eq "=") 1 2 3
47 1 return;
48 }
49 2 $self->{'cgi_pure'}->_parse_params($pair);
50 }
51 0 return;
52 }
53  
54 # Save parameters to file.
55 sub save {
56 1 ▶ my ($self, $fh) = @_;
Subroutine save: called CC=5 SCAR=16.7
Pod documented
57 1 local $OUTPUT_FIELD_SEPARATOR = $EMPTY_STR;
58 1 local $OUTPUT_RECORD_SEPARATOR = $EMPTY_STR;
59 1 ▶ if (! $fh || ! fileno $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh and fileno $fh) 0 1 1
Condition33%1/3
$fh and fileno $fh
!ll&&!rl&&r
001
MC/DC0%0/2
$fh and fileno $fh
$fh fileno $fh
Truth table33%1/3
A and B
A= $fhB= fileno $fh
ABresult
0X0
100
111
60 0 err 'Invalid filehandle.';
61 }
62 1 foreach my $param ($self->{'cgi_pure'}->param) {
63 2 foreach my $value ($self->{'cgi_pure'}->param($param)) {
64 2 print {$fh} uri_escape($param), '=',
65 uri_escape($value), "\n";
66 }
67 }
68 1 print {$fh} "=\n";
69 1 return;
70 }
71  
72 5 1;
73  
74 __END__
« Pure.pm ↑ Summary