| 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::Field::Flex;{ | ||||||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '4.05'; | |||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use parent 'Mail::Message::Field'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Log::Report 'mail-message', import => [ qw// ]; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | #-------------------- | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | sub new($;$$@) | ||||||||||||||||||||||||||||||||
| 26 | 18 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 27 | my $args | ||||||||||||||||||||||||||||||||
| 28 | = @_ <= 2 || ! ref $_[-1] ? {} | ||||||||||||||||||||||||||||||||
| 29 | 18 | ▶ | : ref $_[-1] eq 'ARRAY' ? { @{pop @_} } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
@_ <= 2 or not ref $_[-1]
MC/DC50%1/2
@_ <= 2 or not ref $_[-1]
@_ <= 2
not ref $_[-1]
Truth table66%2/3
A or not(B)
A= @_ <= 2B= not ref $_[-1]
| |||||||||||||||||||||||||||||||||
| 30 | : pop @_; | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 18 | ▶ | my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift)); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 18 | ▶ | defined $body or return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | # Attributes preferably stored in array to protect order. | ||||||||||||||||||||||||||||||||
| 36 | 18 | my $attr = $args->{attributes}; | |||||||||||||||||||||||||||||||
| 37 | 18 | ▶ | $attr = [ %$attr ] if defined $attr && ref $attr eq 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attr and ref $attr eq "HASH"
MC/DC0%0/2
defined $attr and ref $attr eq "HASH"
defined $attr
ref $attr eq "HASH"
Truth table33%1/3
A and B
A= defined $attrB= ref $attr eq "HASH"
| |||||||||||||||||||||||||||||||||
| 38 | 18 | push @$attr, @_; | |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 18 | $class->SUPER::new(%$args, name => $name, body => $body, attributes => $attr); | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | sub init($) | ||||||||||||||||||||||||||||||||
| 44 | 18 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 18 | @$self{ qw/MMFF_name MMFF_body/ } = @$args{ qw/name body/ }; | |||||||||||||||||||||||||||||||
| 47 | 18 | ▶ | $self->comment($args->{comment}) if exists $args->{comment}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 18 | my $attr = $args->{attributes}; | |||||||||||||||||||||||||||||||
| 50 | 18 | ▶ | $self->attribute(shift @$attr, shift @$attr) while @$attr; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 18 | $self; | |||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | sub clone() | ||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 57 | 0 | (ref $self)->new($self->Name, $self->body); | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | sub length() | ||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 62 | 0 | length($self->{MMFF_name}) + 1 + length($self->{MMFF_body}); | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 27 | ▶ | sub name() { lc($_[0]->{MMFF_name}) } | ||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | sub Name() { $_[0]->{MMFF_name} } | ||||||||||||||||||||||||||||||
|
Subroutine
Name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | sub folded(;$) | ||||||||||||||||||||||||||||||||
| 70 | 8 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
folded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | wantarray | ||||||||||||||||||||||||||||||||
| 73 | 8 | ▶ | or return $self->{MMFF_name}.':'.$self->{MMFF_body}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 2 | my @lines = $self->foldedBody; | |||||||||||||||||||||||||||||||
| 76 | 2 | my $first = $self->{MMFF_name}. ':'. shift @lines; | |||||||||||||||||||||||||||||||
| 77 | 2 | ($first, @lines); | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | sub unfoldedBody($;@) | ||||||||||||||||||||||||||||||||
| 81 | 39 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
unfoldedBody: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 82 | 39 | ▶ | $self->{MMFF_body} = $self->fold($self->{MMFF_name}, @_) if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | 39 | $self->unfold($self->{MMFF_body}); | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | sub foldedBody($) | ||||||||||||||||||||||||||||||||
| 87 | 13 | ▶ | { my ($self, $body) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
foldedBody: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 88 | 13 | ▶ | if(@_==2) { $self->{MMFF_body} = $body } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 10 | else { $body = $self->{MMFF_body} } | |||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 13 | ▶ | wantarray ? (split /^/, $body) : $body; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 3 | 1; | |||||||||||||||||||||||||||||||