Message/TransferEnc/EightBit.pm

filter: Statementstmt 100% 32 / 32 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 89.0% 49 / 55 SCAR 19.5
CC
7
Cov
91%
encode
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« Message/Field/Unstructured.pm ↑ Summary Message/TransferEnc/Base64.pm »
1 # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message::TransferEnc::EightBit;
10 8 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 $VERSION = '3.013';
12  
13 8 ▶use base 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub name() { '8bit' }
20  
21 #------------------------------------------
22  
23 sub check($@)
24 1 ▶{ my ($self, $body, %args) = @_;
Subroutine check: called CC=1 SCAR=0.0
Pod documented
25 1 $body;
26 }
27  
28 #------------------------------------------
29  
30 sub decode($@)
31 7 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: called CC=1 SCAR=0.0
Pod documented
32 7 $body->transferEncoding('none');
33 7 $body;
34 }
35  
36 #------------------------------------------
37  
38 sub encode($@)
39 32 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=7 SCAR=19.8
Pod documented
40  
41 32 my @lines;
42 32 my $changes = 0;
43  
44 32 foreach ($body->lines)
45 111 ▶ { $changes++ if s/[\000\013]//g;
Branch: 1 branch
BranchTrueFalseTotal
if s/[\000\013]//g 2 109 111
46  
47 # there shouldn't be any NL inside a line.
48 111 ▶ $changes++ if length > 997;
Branch: 1 branch
BranchTrueFalseTotal
if length $_ > 997 0 111 111
49 111 ▶ push @lines, substr($_, 0, 996, '')."\n"
Branch: 1 branch
BranchTrueFalseTotal
length $_ > 997 and do { push @lines, substr($_, 0, 996, "") . "\n" } 0 111 111
50 while length > 997;
51  
52 111 push @lines, $_;
53 }
54  
55 32 ▶ unless($changes)
Branch: 1 branch
BranchTrueFalseTotal
unless ($changes) 31 1 32
56 31 { $body->transferEncoding('8bit');
57 31 return $body;
58 }
59  
60 1 ▶ my $bodytype = $args{result_type} || ref $body;
Condition33%1/3
$args{'result_type'} || ref $body
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{'result_type'} || ref $body
$args{'result_type'} ref $body
Truth table33%1/3
A || B
A= $args{'result_type'}B= ref $body
ABresult
1X1
011
000
61  
62 1 $bodytype->new
63 ( based_on => $body
64 , transfer_encoding => '8bit'
65 , data => \@lines
66 );
67 }
68  
69 #------------------------------------------
70  
71 8 1;
« Message/Field/Unstructured.pm ↑ Summary Message/TransferEnc/Base64.pm »