Message/TransferEnc/Base64.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 66.6% 4 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 80.3% 41 / 51 CC 5 SCAR 8.8
CC
5
Cov
82%
decode
4.5
encode
2.0
check
2.0
CRAP 2.4
« Message/Field/Address.pm ↑ Summary Message/Construct.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::Base64;
10 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 $VERSION = '3.012';
12  
13 5 ▶use base 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 sub name() { 'base64' }
22  
23 #------------------------------------------
24  
25 sub check($@)
26 0 ▶{ my ($self, $body, %args) = @_;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
27 0 $body;
28 }
29  
30 #------------------------------------------
31  
32  
33 sub decode($@)
34 2 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: called CC=4 SCAR=15.0
Pod documented
35  
36 2 my $lines = decode_base64($body->string);
37 2 ▶ unless($lines)
Branch: 1 branch
BranchTrueFalseTotal
unless ($lines) 0 2 2
38 0 { $body->transferEncoding('none');
39 0 return $body;
40 }
41
42 my $bodytype
43 = defined $args{result_type} ? $args{result_type}
44 2 ▶ : $body->isBinary ? 'Mail::Message::Body::File'
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'result_type'} ? : 1 1 2
$body->isBinary ? : 0 1 1
45 : ref $body;
46  
47 2 $bodytype->new
48 ( based_on => $body
49 , transfer_encoding => 'none'
50 , data => $lines
51 );
52 }
53  
54 #------------------------------------------
55  
56 sub encode($@)
57 4 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=2 SCAR=7.0
Pod documented
58  
59 4 ▶ my $bodytype = $args{result_type} || ref $body;
Condition66%2/3
$args{'result_type'} || ref $body
l!l&&r!l&&!r
310
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
60  
61 4 $bodytype->new
62 ( based_on => $body
63 , checked => 1
64 , transfer_encoding => 'base64'
65 , data => encode_base64($body->string)
66 );
67 }
68  
69 #------------------------------------------
70  
71 5 1;
« Message/Field/Address.pm ↑ Summary Message/Construct.pm »