| 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::Nested;{ | ||||||||||||||||||||
| 13 | 37 | our $VERSION = '4.05'; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 37 | ▶ | use parent 'Mail::Message::Body'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 37 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 37 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 37 | ▶ | use Log::Report 'mail-message', import => [ qw/__x error/ ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 37 | ▶ | use Mail::Message::Body::Lines (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 37 | ▶ | use Mail::Message::Part (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | #-------------------- | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub init($) | ||||||||||||||||||||
| 29 | 12 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 30 | 12 | ▶ | $args->{mime_type} ||= 'message/rfc822'; | ||||||||||||||||||
|
Condition50%1/2
$args->{"mime_type"} ||= "message/rfc822"
MC/DC0%0/1
$args->{"mime_type"} ||= "message/rfc822"
$args->{"mime_type"}
Truth table50%1/2
A
A= $args->{"mime_type"}
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 12 | $self->SUPER::init($args); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 12 | my $nested; | |||||||||||||||||||
| 35 | 12 | ▶ | if(my $raw = $args->{nested}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 11 | ▶ | { $nested = Mail::Message::Part->coerce($raw, $self) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | or error __x"data not convertible to a message (type is {class})", class => ref $raw; | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 12 | $self->{MMBN_nested} = $nested; | |||||||||||||||||||
| 41 | 12 | $self; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | sub clone() | ||||||||||||||||||||
| 45 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 46 | 1 | (ref $self)->new(based_on => $self, nested => $self->nested->clone); | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | sub isNested() { 1 } | ||||||||||||||||||||
| 50 | 0 | ▶ | sub isBinary() { $_[0]->nested->body->isBinary } | ||||||||||||||||||
|
Subroutine
isBinary: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 51 | 11 | ▶ | sub nrLines() { $_[0]->nested->nrLines } | ||||||||||||||||||
|
Subroutine
nrLines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 52 | 13 | ▶ | sub size() { $_[0]->nested->size } | ||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 1 | ▶ | sub string() { my $nested = $_[0]->nested; defined $nested ? $nested->string : '' } | ||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | ▶ | sub lines() { my $nested = $_[0]->nested; defined $nested ? $nested->lines : () } | ||||||||||||||||||
|
Subroutine
lines: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 0 | ▶ | sub file() { my $nested = $_[0]->nested; defined $nested ? $nested->file : undef } | ||||||||||||||||||
|
Subroutine
file: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 3 | ▶ | sub print(;$) { my $self = shift; $self->nested->print(shift || select) } | ||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=8.1
Pod
documented
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 58 | 2 | ▶ | sub endsOnNewline() { $_[0]->nested->body->endsOnNewline } | ||||||||||||||||||
|
Subroutine
endsOnNewline: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub partNumberOf($) | ||||||||||||||||||||
| 61 | 3 | ▶ | { my ($self, $part) = @_; | ||||||||||||||||||
|
Subroutine
partNumberOf: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 62 | 3 | ▶ | $self->message->partNumber || '1'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | sub foreachLine($) | ||||||||||||||||||||
| 67 | 0 | ▶ | { my ($self, $code) = @_; | ||||||||||||||||||
|
Subroutine
foreachLine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 68 | 0 | error __x"you cannot use foreachLine on a nested."; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | ▶ | sub check() { $_[0]->forNested( sub { $_[1]->check } ) } | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
check: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub encode(@) | ||||||||||||||||||||
| 74 | 1 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||
|
Subroutine
encode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 75 | 1 | ▶ | $self->forNested( sub { $_[1]->encode(%args) } ); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 7 | ▶ | sub encoded() { $_[0]->forNested( sub { $_[1]->encoded } ) } | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
encoded: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | sub read($$$$) | ||||||||||||||||||||
| 81 | 1 | ▶ | { my ($self, $parser, $head, $bodytype) = @_; | ||||||||||||||||||
|
Subroutine
read: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 1 | my $nest = Mail::Message::Part->new(container => undef); | |||||||||||||||||||
| 84 | 1 | ▶ | $nest->readFromParser($parser, $bodytype) or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 1 | $nest->container($self); | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 1 | $self->{MMBN_nested} = $nest; | |||||||||||||||||||
| 88 | 1 | $self; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | sub fileLocation() | ||||||||||||||||||||
| 92 | 0 | ▶ | { my $nested = $_[0]->nested; | ||||||||||||||||||
|
Subroutine
fileLocation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 93 | 0 | ( ($nested->head->fileLocation)[0], ($nested->body->fileLocation)[1] ); | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | sub moveLocation($) | ||||||||||||||||||||
| 97 | 0 | ▶ | { my ($self, $dest) = @_; | ||||||||||||||||||
|
Subroutine
moveLocation: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 98 | 0 | ▶ | $dest or return $self; # no move | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | my $nested = $self->nested; | |||||||||||||||||||
| 101 | 0 | $nested->head->moveLocation($dest); | |||||||||||||||||||
| 102 | 0 | $nested->body->moveLocation($dest); | |||||||||||||||||||
| 103 | 0 | $self; | |||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | #-------------------- | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 63 | ▶ | sub nested() { $_[0]->{MMBN_nested} } | ||||||||||||||||||
|
Subroutine
nested: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | sub forNested($) | ||||||||||||||||||||
| 112 | 8 | ▶ | { my ($self, $code) = @_; | ||||||||||||||||||
|
Subroutine
forNested: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 113 | 8 | my $nested = $self->nested; | |||||||||||||||||||
| 114 | 8 | my $body = $nested->body; | |||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 8 | ▶ | my $new_body = $code->($self, $body) or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | 8 | ▶ | $new_body != $body or return $self; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 3 | my $new_nested = Mail::Message::Part->new(head => $nested->head->clone, container => undef); | |||||||||||||||||||
| 120 | 3 | $new_nested->body($new_body); | |||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 3 | my $created = (ref $self)->new(based_on => $self, nested => $new_nested); | |||||||||||||||||||
| 123 | 3 | $new_nested->container($created); | |||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 3 | $created; | |||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 0 | ▶ | sub toplevel() { my $msg = $_[0]->message; $msg ? $msg->toplevel : undef} | ||||||||||||||||||
|
Subroutine
toplevel: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 37 | 1; | |||||||||||||||||||