Encoded/Coder/Encode.pm

filter: Statementstmt 100% 41 / 41 Branchbran 71.4% 10 / 14 Conditioncond 57.8% 11 / 19 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 100% 12 / 12 Podpod 83.3% 5 / 6 totaltotal 79.4% 81 / 102 CC 18 SCAR 13.9
CC
18
Cov
84%
decode_fields_ref
6.3
find_encoding
6.2
encode_fields_ref
4.2
CRAP 4.0
« Encoded/Coder/EncodeGuess.pm ↑ Summary Encoded/Coder/Base.pm »
1 package Text::CSV::Encoded::Coder::Encode;
2 11 $Text::CSV::Encoded::Coder::Encode::VERSION = '0.25';
3 11 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # VERSION
8  
9 11 ▶use base qw( Text::CSV::Encoded::Coder::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 11 my %EncoderCache;
15  
16  
17 9 ▶sub upgrade {
Subroutine upgrade: called CC=2 SCAR=7.6
Pod documented
18 9 ▶ utf8::upgrade( $_[1] ) if ( $_[1] );
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 9 0 9
19 }
20  
21  
22 55 ▶sub encode {
Subroutine encode: called CC=2 SCAR=7.1
Pod documented
23 55 my ( $self, $encoding, $str ) = @_;
24 55 ▶ return undef unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 0 55 55
25 55 $self->find_encoding( $encoding )->encode( $str, $self->encode_check_value );
26 }
27  
28  
29 73 ▶sub decode {
Subroutine decode: called CC=4 SCAR=13.9
Pod documented
30 73 my ( $self, $encoding, $str ) = @_;
31 73 ▶ return undef unless defined $str;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $str 1 72 73
32  
33 72 ▶ if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i) 46 26 72
Condition66%2/3
$self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i
!ll&&!rl&&r
02646
MC/DC50%1/2
$self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i
$self->{"automatic_UTF8"} $encoding =~ /utf-?8/i
Truth table66%2/3
A and B
A= $self->{"automatic_UTF8"}B= $encoding =~ /utf-?8/i
ABresult
0X0
100
111
34 46 return $str;
35 }
36  
37 26 $self->find_encoding( $encoding )->decode( $str, $self->decode_check_value );
38 }
39  
40  
41 42 ▶sub decode_fields_ref {
Subroutine decode_fields_ref: called CC=6 SCAR=18.4
Pod documented
42 42 my ( $self, $encoding, $arrayref ) = @_;
43  
44 42 ▶ if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i) 10 32 42
Condition66%2/3
$self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i
!ll&&!rl&&r
03210
MC/DC50%1/2
$self->{"automatic_UTF8"} and $encoding =~ /utf-?8/i
$self->{"automatic_UTF8"} $encoding =~ /utf-?8/i
Truth table66%2/3
A and B
A= $self->{"automatic_UTF8"}B= $encoding =~ /utf-?8/i
ABresult
0X0
100
111
45 10 return;
46 }
47  
48 32 ▶ my $enc = $self->find_encoding( $encoding ) || return;
Condition50%1/2
$self->find_encoding($encoding) || (return)
l!l
320
MC/DC0%0/1
$self->find_encoding($encoding) || (return)
$self->find_encoding($encoding)
Truth table50%1/2
A
A= $self->find_encoding($encoding)
Aresult
11
00
49 32 for ( @$arrayref ) {
50 32 ▶ $_ = $enc->decode( $_, $self->decode_check_value ) if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 32 0 32
51 }
52 }
53  
54  
55 24 ▶sub encode_fields_ref {
Subroutine encode_fields_ref: called CC=4 SCAR=14.5
Pod documented
56 24 my ( $self, $encoding, $arrayref ) = @_;
57 24 ▶ my $enc = $self->find_encoding( $encoding ) || return;
Condition50%1/2
$self->find_encoding($encoding) || (return)
l!l
240
MC/DC0%0/1
$self->find_encoding($encoding) || (return)
$self->find_encoding($encoding)
Truth table50%1/2
A
A= $self->find_encoding($encoding)
Aresult
11
00
58 24 for ( @$arrayref ) {
59 24 ▶ $_ = $enc->encode( $_, $self->encode_check_value ) if defined $_;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 24 0 24
60 }
61 }
62  
63  
64 137 ▶sub find_encoding {
Subroutine find_encoding: called CC=5 SCAR=18.2
Pod undocumented
65 137 shift;
66 137 ▶ $EncoderCache { ($_[0] || 'utf8') }
Condition55%5/9
$EncoderCache{$_[0] or "utf8"} ||= &Encode::find_encoding(scalar($_[0] || "utf8")) || Carp::croak("Not found such an encoding name '$_[0]'")
l!l&&r!l&&!r
118190
$_[0] || 'utf8'
l!l
1370
&Encode::find_encoding(scalar($_[0] || 'utf8')) || Carp::croak("Not found such an encoding name '$_[0]'")
l!l
190
$_[0] || 'utf8'
l!l
190
MC/DC0%0/2
$EncoderCache{$_[0] or "utf8"} ||= &Encode::find_encoding(scalar($_[0] || "utf8")) || Carp::croak("Not found such an encoding name '$_[0]'")
$EncoderCache{$_[0] or "utf8"} &Encode::find_encoding(scalar($_[0] || 'utf8'))
MC/DC0%0/1
$_[0] || 'utf8'
$_[0]
MC/DC0%0/1
$_[0] || 'utf8'
$_[0]
Truth table66%2/3
A ||= B
A= $EncoderCache{$_[0] or "utf8"}B= &Encode::find_encoding(scalar($_[0] || 'utf8'))
ABresult
1X1
011
000
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
67 ||= Encode::find_encoding( $_[0] || 'utf8' ) || Carp::croak ( "Not found such an encoding name '$_[0]'" );
68 }
69  
70  
71  
72 11 1;
73 __END__
« Encoded/Coder/EncodeGuess.pm ↑ Summary Encoded/Coder/Base.pm »