blib/lib/HTML/FillInForm/ForceUTF8.pm

filter: Statementstmt 78.7% 26 / 33 Branchbran 35.7% 5 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 66.1% 39 / 59 CC 11 SCAR 25.8
CC
11
Cov
64%
fill
24.0
_get_param
4.0
BEGIN
1.0
CRAP 13.2
↑ Summary
1 package HTML::FillInForm::ForceUTF8;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw(HTML::FillInForm);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.03';
9  
10 2 ▶sub fill {
Subroutine fill: called CC=8 SCAR=31.8
Pod documented
11 2 my ( $self, %option ) = @_;
12 2 ▶ if ( exists $option{file} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $option{'file'}) { } 0 2 2
elsif (exists $option{'scalarref'} and not &Encode::is_utf8($option{'scalarref'})) { } 2 0 2
elsif (exists $option{'arrayref'}) { } 0 0 0
13 0 ▶ if ( ref $option{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option{'file'}) { } 0 0 0
14 0 binmode $option{file}, ":utf8";
15 }
16 else {
17 0 open my $fh, ":utf8", $option{file};
18 0 $option{file} = $fh;
19 }
20 }
21 ▶ elsif ( exists $option{scalarref} && !Encode::is_utf8($option{scalarref}) ) {
Condition33%1/3
exists $option{"scalarref"} and not &Encode::is_utf8($option{"scalarref"})
!ll&&!rl&&r
002
MC/DC0%0/2
exists $option{"scalarref"} and not &Encode::is_utf8($option{"scalarref"})
exists $option{"scalarref"} not &Encode::is_utf8($option{"scalarref"})
Truth table33%1/3
A and not(B)
A= exists $option{"scalarref"}B= not &Encode::is_utf8($option{"scalarref"})
ABresult
0X0
100
111
22 2 my $val = ${$option{scalarref}};
23 2 Encode::_utf8_on( $val );
24 2 $option{scalarref} = \$val;
25 }
26 elsif ( exists $option{arrayref} ) {
27 0 for ( @{ $option{arrayref} } ) {
28 0 ▶ Encode::_utf8_on($_) unless Encode::is_utf8($_);
Branch: 1 branch
BranchTrueFalseTotal
unless &Encode::is_utf8($_) 0 0 0
29 }
30 }
31 2 $self->SUPER::fill(%option);
32 }
33  
34 2 ▶sub _get_param {
Subroutine _get_param: called CC=4 SCAR=13.9
35 2 my $self = shift;
36 2 my $ret = $self->SUPER::_get_param(@_);
37 2 ▶ for ( ref($ret) ? @$ret : $ret ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $ret ? : 0 2 2
38 2 ▶ Encode::_utf8_on($_) unless Encode::is_utf8($_);
Branch: 1 branch
BranchTrueFalseTotal
unless &Encode::is_utf8($_) 1 1 2
39 }
40 2 return $ret;
41 }
42  
43 2 1;
44 __END__
↑ Summary