Message/TransferEnc/SevenBit.pm

filter: Statementstmt 79.4% 27 / 34 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 72.8% 43 / 59 CC 8 SCAR 17.4
CC
8
Cov
74%
encode
9.0
check
2.0
decode
2.0
CRAP 5.7
« Message/Body/File.pm ↑ Summary Box/Parser.pm »
1 # Copyrights 2001-2022 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::SevenBit;
10 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 $VERSION = '3.012';
12  
13 3 ▶use base 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub name() { '7bit' }
20  
21 #------------------------------------------
22  
23 sub check($@)
24 0 ▶{ my ($self, $body, %args) = @_;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
25 0 $body;
26 }
27  
28 #------------------------------------------
29  
30 sub decode($@)
31 0 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: not called CC=1 SCAR=6.9
Pod documented
32 0 $body->transferEncoding('none');
33 0 $body;
34 }
35  
36 #------------------------------------------
37  
38 sub encode($@)
39 2 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=8 SCAR=22.0
Pod documented
40  
41 2 my @lines;
42 2 my $changes = 0;
43  
44 2 foreach ($body->lines)
45 4 ▶ { $changes++ if s/([^\000-\127])/chr(ord($1) & 0x7f)/ge;
Branch: 1 branch
BranchTrueFalseTotal
if s/([^\000-\127])/chr(ord $1 & 127);/eg 4 0 4
46 4 ▶ $changes++ if s/[\000\013]//g;
Branch: 1 branch
BranchTrueFalseTotal
if s/[\000\013]//g 2 2 4
47  
48 4 ▶ $changes++ if length > 997;
Branch: 1 branch
BranchTrueFalseTotal
if length $_ > 997 0 4 4
49 4 ▶ push @lines, substr($_, 0, 996, '')."\n"
Branch: 1 branch
BranchTrueFalseTotal
length $_ > 997 and do { push @lines, substr($_, 0, 996, "") . "\n" } 0 4 4
50 while length > 997;
51  
52 4 push @lines, $_;
53 }
54  
55 2 ▶ unless($changes)
Branch: 1 branch
BranchTrueFalseTotal
unless ($changes) 0 2 2
56 0 { $body->transferEncoding('7bit');
57 0 return $body;
58 }
59  
60 2 ▶ my $bodytype = $args{result_type} || ref $body;
Condition66%2/3
$args{'result_type'} || ref $body
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{'result_type'} || ref $body
$args{'result_type'} ref $body
Truth table66%2/3
A || B
A= $args{'result_type'}B= ref $body
ABresult
1X1
011
000
61  
62 2 $bodytype->new
63 ( based_on => $body
64 , transfer_encoding => '7bit'
65 , data => \@lines
66 );
67 }
68  
69 #------------------------------------------
70  
71 3 1;
« Message/Body/File.pm ↑ Summary Box/Parser.pm »