Encoded/Coder/EncodeGuess.pm

filter: Statementstmt 89.4% 34 / 38 Branchbran 50.0% 5 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 80.6% 50 / 62 CC 9 SCAR 15.8
CC
9
Cov
78%
decode_fields_ref
9.7
decode
4.5
BEGIN
1.0
CRAP 4.9
« Encoded.pm ↑ Summary Encoded/Coder/Encode.pm »
1 package Text::CSV::Encoded::Coder::EncodeGuess;
2 1 $Text::CSV::Encoded::Coder::EncodeGuess::VERSION = '0.25';
3 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # VERSION
8  
9 1 ▶use base qw( Text::CSV::Encoded::Coder::Encode );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Encode::Guess;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 2 ▶sub decode {
Subroutine decode: called CC=4 SCAR=15.0
Pod documented
17 2 my ( $self, $encoding, $str ) = @_;
18  
19 2 ▶ return undef unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 2 2
20  
21 2 ▶ if ( ref $encoding ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $encoding) 2 0 2
22 2 my $enc = Encode::Guess::guess_encoding( $str, @$encoding );
23 2 ▶ $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $enc 0 2 2
24 2 return $enc->decode( $str, $self->decode_check_value );
25 }
26  
27 0 $self->find_encoding( $encoding )->decode( $str, $self->decode_check_value );
28 }
29  
30  
31 1 ▶sub decode_fields_ref {
Subroutine decode_fields_ref: called CC=6 SCAR=22.7
Pod documented
32 1 my ( $self, $encoding, $arrayref ) = @_;
33  
34 1 ▶ if ( ref $encoding ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $encoding) { } 1 0 1
35 1 for ( @$arrayref ) {
36 2 my $enc = Encode::Guess::guess_encoding( $_, @$encoding );
37 2 ▶ $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $enc 0 2 2
38 2 $_ = $enc->decode( $_, $self->decode_check_value );
39 }
40 }
41 else {
42 0 ▶ my $enc = $self->find_encoding( $encoding ) || return;
Condition0%0/2
$self->find_encoding($encoding) || (return)
l!l
00
MC/DC0%0/1
$self->find_encoding($encoding) || (return)
$self->find_encoding($encoding)
Truth table0%0/2
A
A= $self->find_encoding($encoding)
Aresult
11
00
43 0 for ( @$arrayref ) {
44 0 $_ = $enc->decode( $_, $self->decode_check_value );
45 }
46 }
47  
48 }
49  
50  
51 1 1;
52 __END__
« Encoded.pm ↑ Summary Encoded/Coder/Encode.pm »