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 # Pragmas.
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Modules.
8 5 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # Constants.
15 5 Readonly::Scalar my $EMPTY_STR => q{};
16  
17 # Version.
18 5 our $VERSION = 0.07;
19  
20 # Constructor.
21 sub new {
22 4 ▶ my ($class, @params) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
23 4 my $self = bless {}, $class;
24  
25 # CGI::Pure object.
26 4 $self->{'cgi_pure'} = $EMPTY_STR;
27  
28 # Process params.
29 4 set_params($self, @params);
30  
31 # CGI::Pure object not exist.
32 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
33 1 err 'CGI::Pure object doesn\'t define.';
34 }
35  
36 # Object.
37 3 return $self;
38 }
39  
40 # Load parameters from file.
41 sub load {
42 1 ▶ my ($self, $fh) = @_;
Subroutine load: called CC=5 SCAR=17.6
Pod documented
43 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
44 0 err 'Invalid filehandle.';
45 }
46 1 local $INPUT_RECORD_SEPARATOR = "\n";
47 1 ▶ while (my $pair = <$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $pair = readline $fh)) 3 0 3
48 3 chomp $pair;
49 3 ▶ if ($pair eq q{=}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pair eq "=") 1 2 3
50 1 return;
51 }
52 2 $self->{'cgi_pure'}->_parse_params($pair);
53 }
54 0 return;
55 }
56  
57 # Save parameters to file.
58 sub save {
59 1 ▶ my ($self, $fh) = @_;
Subroutine save: called CC=5 SCAR=16.7
Pod documented
60 1 local $OUTPUT_FIELD_SEPARATOR = $EMPTY_STR;
61 1 local $OUTPUT_RECORD_SEPARATOR = $EMPTY_STR;
62 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
63 0 err 'Invalid filehandle.';
64 }
65 1 foreach my $param ($self->{'cgi_pure'}->param) {
66 2 foreach my $value ($self->{'cgi_pure'}->param($param)) {
67 2 print {$fh} uri_escape($param), '=',
68 uri_escape($value), "\n";
69 }
70 }
71 1 print {$fh} "=\n";
72 1 return;
73 }
74  
75 5 1;
76  
77 __END__
« Pure.pm ↑ Summary