| 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::Body::String;{ | ||||||||||||||||||||
| 13 | 8 | our $VERSION = '4.05'; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 8 | ▶ | use parent 'Mail::Message::Body'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 8 | ▶ | use Log::Report 'mail-message', import => [ qw/__x fault/ ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 8 | ▶ | use Mail::Box::FastScalar (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | #-------------------- | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # The scalar is stored as reference to avoid a copy during creation of | ||||||||||||||||||||
| 28 | # a string object. | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | sub _data_from_filename(@) | ||||||||||||||||||||
| 31 | 0 | ▶ | { my ($self, $filename) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | delete $self->{MMBS_nrlines}; | |||||||||||||||||||
| 34 | 0 | ▶ | open my $in, '<:raw', $filename | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | or fault __x"unable to read file {name} for message body scalar", name => $filename; | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | my @lines = $in->getlines; | |||||||||||||||||||
| 38 | 0 | $in->close; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | $self->{MMBS_nrlines} = @lines; | |||||||||||||||||||
| 41 | 0 | $self->{MMBS_scalar} = join '', @lines; | |||||||||||||||||||
| 42 | 0 | $self; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | sub _data_from_filehandle(@) | ||||||||||||||||||||
| 46 | 1 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_filehandle: called CC=2 SCAR=7.8
| |||||||||||||||||||||
| 47 | 1 | ▶ | if(ref $fh eq 'Mail::Box::FastScalar') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 0 | { my $lines = $fh->getlines; | |||||||||||||||||||
| 49 | 0 | $self->{MMBS_nrlines} = @$lines; | |||||||||||||||||||
| 50 | 0 | $self->{MMBS_scalar} = join '', @$lines; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | else | ||||||||||||||||||||
| 53 | 1 | { my @lines = $fh->getlines; | |||||||||||||||||||
| 54 | 1 | $self->{MMBS_nrlines} = @lines; | |||||||||||||||||||
| 55 | 1 | $self->{MMBS_scalar} = join '', @lines; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | 1 | $self; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub _data_from_lines(@) | ||||||||||||||||||||
| 61 | 1 | ▶ | { my ($self, $lines) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_lines: called CC=3 SCAR=11.4
| |||||||||||||||||||||
| 62 | 1 | ▶ | $self->{MMBS_nrlines} = @$lines unless @$lines==1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 1 | ▶ | $self->{MMBS_scalar} = @$lines==1 ? shift @$lines : join('', @$lines); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 1 | $self; | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | sub clone() | ||||||||||||||||||||
| 68 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 69 | 0 | (ref $self)->new(data => $self->string, based_on => $self); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | sub nrLines() | ||||||||||||||||||||
| 73 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
nrLines: called CC=3 SCAR=17.3
Pod
documented
| |||||||||||||||||||||
| 74 | 2 | ▶ | return $self->{MMBS_nrlines} if defined $self->{MMBS_nrlines}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | my $lines = $self->{MMBS_scalar} =~ tr/\n/\n/; | |||||||||||||||||||
| 77 | 0 | ▶ | $lines++ if $self->{MMBS_scalar} !~ m/\n\z/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 0 | $self->{MMBS_nrlines} = $lines; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 2 | ▶ | sub size() { length $_[0]->{MMBS_scalar} } | ||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 82 | 3 | ▶ | sub string() { $_[0]->{MMBS_scalar} } | ||||||||||||||||||
|
Subroutine
string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | sub lines() | ||||||||||||||||||||
| 85 | 3 | ▶ | { my @lines = split /^/, shift->{MMBS_scalar}; | ||||||||||||||||||
|
Subroutine
lines: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 86 | 3 | ▶ | wantarray ? @lines : \@lines; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | ▶ | sub file() { Mail::Box::FastScalar->new(\shift->{MMBS_scalar}) } | ||||||||||||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | sub print(;$) | ||||||||||||||||||||
| 92 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 93 | 2 | ▶ | my $fh = shift || select; | ||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 94 | 2 | $fh->print($self->{MMBS_scalar}); | |||||||||||||||||||
| 95 | 2 | $self; | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | sub read($$;$@) | ||||||||||||||||||||
| 99 | 0 | ▶ | { my ($self, $parser, $head, $bodytype) = splice @_, 0, 4; | ||||||||||||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 100 | 0 | delete $self->{MMBS_nrlines}; | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | (my $begin, my $end, $self->{MMBS_scalar}) = $parser->bodyAsString(@_); | |||||||||||||||||||
| 103 | 0 | $self->fileLocation($begin, $end); | |||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 0 | $self; | |||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 0 | ▶ | sub endsOnNewline() { $_[0]->{MMBS_scalar} =~ m/\A\z|\n\z/ } | ||||||||||||||||||
|
Subroutine
endsOnNewline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 8 | 1; | |||||||||||||||||||