Message/Construct/Read.pm

filter: Statementstmt 95.7% 45 / 47 Branchbran 93.7% 15 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.6% 68 / 75 SCAR 23.1
CC
10
Cov
92%
read
10.1
BEGIN
1.0
BEGIN
1.0
CRAP 10.0
« Message/TransferEnc/Binary.pm ↑ Summary Message/Field/AddrGroup.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;
10 6 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 $VERSION = '3.013';
12  
13  
14 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 6 ▶use Mail::Box::FastScalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use Mail::Box::Parser::Perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 sub read($@)
22 12 ▶{ my ($class, $from, %args) = @_;
Subroutine read: called CC=10 SCAR=23.1
Pod documented
23  
24 12 my ($filename, $file);
25 12 my $ref = ref $from;
26 12 ▶ if(!$ref)
Branch: 5 branches
BranchTrueFalseTotal
if (not $ref) { } 8 4 12
elsif ($ref eq 'SCALAR') { } 1 3 4
elsif ($ref eq 'ARRAY') { } 1 2 3
elsif ($ref eq 'GLOB') { } 1 1 2
elsif ($ref and $from->isa('IO::Handle')) { } 1 0 1
27 8 { $filename = 'scalar';
28 8 $file = Mail::Box::FastScalar->new(\$from);
29 }
30 elsif($ref eq 'SCALAR')
31 1 { $filename = 'ref scalar';
32 1 $file = Mail::Box::FastScalar->new($from);
33 }
34 elsif($ref eq 'ARRAY')
35 1 { $filename = 'array of lines';
36 1 my $buffer= join '', @$from;
37 1 $file = Mail::Box::FastScalar->new(\$buffer);
38 }
39 elsif($ref eq 'GLOB')
40 1 { $filename = 'file (GLOB)';
41 1 local $/;
42 1 my $buffer= <$from>;
43 1 $file = Mail::Box::FastScalar->new(\$buffer);
44 }
45 ▶ elsif($ref && $from->isa('IO::Handle'))
Condition33%1/3
$ref and $from->isa("IO::Handle")
!ll&&!rl&&r
001
MC/DC0%0/2
$ref and $from->isa("IO::Handle")
$ref $from->isa("IO::Handle")
Truth table33%1/3
A and B
A= $refB= $from->isa("IO::Handle")
ABresult
0X0
100
111
46 1 { $filename = 'file ('.ref($from).')';
47 1 my $buffer= join '', $from->getlines;
48 1 $file = Mail::Box::FastScalar->new(\$buffer);
49 }
50 else
51 0 { $class->log(ERROR => "Cannot read from $from");
52 0 return undef;
53 }
54  
55 my $strip_status
56 = exists $args{strip_status_fields}
57 ? delete $args{strip_status_fields}
58 12 ▶ : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'strip_status_fields'} ? : 2 10 12
59  
60 # Not parseable by the C implementation
61 12 my $parser = Mail::Box::Parser::Perl->new
62 ( %args
63 , filename => $filename
64 , file => $file
65 , trusted => 1
66 );
67  
68 12 my $self = $class->new(%args);
69 12 $self->readFromParser($parser, $args{body_type});
70 12 $self->addReport($parser);
71  
72 12 $parser->stop;
73  
74 12 my $head = $self->head;
75 12 ▶ $head->get('Message-ID')
Branch: 1 branch
BranchTrueFalseTotal
$head->get("Message-ID") or $head->set("Message-ID", '<' . $self->messageId . '>') 11 1 12
76 or $head->set('Message-ID' => '<'.$self->messageId.'>');
77  
78 12 ▶ $head->delete('Status', 'X-Status') if $strip_status;
Branch: 1 branch
BranchTrueFalseTotal
if $strip_status 10 2 12
79  
80 12 $self;
81 }
82  
83 6 1;
« Message/TransferEnc/Binary.pm ↑ Summary Message/Field/AddrGroup.pm »