Message/TransferEnc/Base64.pm

filter: Statementstmt 87.8% 29 / 33 Branchbran 50.0% 2 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 77.9% 46 / 59 CC 5 SCAR 8.7
CC
5
Cov
81%
decode
4.7
encode
2.0
check
2.0
CRAP 2.4
« Message/Field/Fast.pm ↑ Summary Message/Construct.pm »
1 # This code is part of Perl distribution Mail-Message version 4.05.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Message::TransferEnc::Base64;{
13 5 our $VERSION = '4.05';
14 }
15  
16 5 ▶use parent 'Mail::Message::TransferEnc';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 5 ▶use Log::Report 'mail-message', import => [ qw/warning/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 5 ▶use MIME::Base64 qw/decode_base64 encode_base64/;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 #--------------------
27  
28 sub name() { 'base64' }
29  
30 sub check($@)
31 0 ▶{ my ($self, $body, %args) = @_;
Subroutine check: not called CC=1 SCAR=6.9
Pod documented
32 0 $body;
33 }
34  
35  
36 sub decode($@)
37 2 ▶{ my ($self, $body, %args) = @_;
Subroutine decode: called CC=4 SCAR=15.5
Pod documented
38  
39 2 my $lines = decode_base64($body->string);
40 2 ▶ unless($lines)
Branch: 1 branch
BranchTrueFalseTotal
unless ($lines) 0 2 2
41 0 { $body->transferEncoding('none');
42 0 return $body;
43 }
44  
45 2 ▶ my $bodytype = $args{result_type} || ($body->isBinary ? 'Mail::Message::Body::File' : ref $body);
Branch: 1 branch
BranchTrueFalseTotal
$body->isBinary ? : 0 1 1
Condition66%2/3
$args{'result_type'} || ($body->isBinary ? 'Mail::Message::Body::File' : ref $body)
l!l&&r!l&&!r
110
MC/DC0%0/2
$args{'result_type'} || ($body->isBinary ? 'Mail::Message::Body::File' : ref $body)
$args{'result_type'} ($body->isBinary ? 'Mail::Message::Body::File' : ref $body)
Truth table66%2/3
A || B
A= $args{'result_type'}B= ($body->isBinary ? 'Mail::Message::Body::File' : ref $body)
ABresult
1X1
011
000
46 2 $bodytype->new(based_on => $body, transfer_encoding => 'none', data => $lines);
47 }
48  
49 sub encode($@)
50 4 ▶{ my ($self, $body, %args) = @_;
Subroutine encode: called CC=2 SCAR=7.0
Pod documented
51 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
52  
53 4 $bodytype->new(
54 based_on => $body,
55 checked => 1,
56 transfer_encoding => 'base64',
57 data => encode_base64($body->string),
58 );
59 }
60  
61 5 1;
« Message/Field/Fast.pm ↑ Summary Message/Construct.pm »