| 1 | # Copyrights 2001-2022 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::Field::Address; | ||||||||||
| 10 | 23 | ▶ | use vars '$VERSION'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 23 | $VERSION = '3.012'; | |||||||||
| 12 | |||||||||||
| 13 | 23 | ▶ | use base 'Mail::Identity'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 23 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 23 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 23 | ▶ | use Mail::Message::Field::Addresses; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 23 | ▶ | use Mail::Message::Field::Full; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 23 | my $format = 'Mail::Message::Field::Full'; | |||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | use overload | ||||||||||
| 25 | '""' => 'string' | ||||||||||
| 26 | 24 | ▶ | , bool => sub {1} | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 0 | ▶ | , cmp => sub { lc($_[0]->address) eq lc($_[1]) } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | 23 | ▶ | ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | #------------------------------------------ | ||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | sub coerce($@) | ||||||||||
| 34 | 32 | ▶ | { my ($class, $addr, %args) = @_; | ||||||||
|
Subroutine
coerce: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||
| 35 | 32 | ▶ | return () unless defined $addr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | 32 | ▶ | ref $addr or return $class->parse($addr); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 31 | ▶ | $addr->isa($class) and return $addr; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | 4 | my $from = $class->from($addr, %args); | |||||||||
| 41 | |||||||||||
| 42 | 4 | ▶ | Mail::Reporter->log(ERROR => "Cannot coerce a ".ref($addr)." into a $class"), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | return () unless defined $from; | ||||||||||
| 44 | |||||||||||
| 45 | 4 | bless $from, $class; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | sub init($) | ||||||||||
| 49 | 24 | ▶ | { my ($self, $args) = @_; | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 50 | 24 | $self->SUPER::init($args); | |||||||||
| 51 | 24 | $self->{MMFA_encoding} = delete $args->{encoding}; | |||||||||
| 52 | 24 | $self; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | sub parse($) | ||||||||||
| 57 | 3 | ▶ | { my $self = shift; | ||||||||
|
Subroutine
parse: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 58 | 3 | my $parsed = Mail::Message::Field::Addresses->new(To => shift); | |||||||||
| 59 | 3 | ▶ | defined $parsed ? ($parsed->addresses)[0] : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | #------------------------------------------ | ||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | 83 | ▶ | sub encoding() {shift->{MMFA_encoding}} | ||||||||
|
Subroutine
encoding: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 66 | |||||||||||
| 67 | #------------------------------------------ | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | sub string() | ||||||||||
| 71 | 83 | ▶ | { my $self = shift; | ||||||||
|
Subroutine
string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 72 | 83 | my @opts = (charset => $self->charset, encoding => $self->encoding); | |||||||||
| 73 | # language => $self->language | ||||||||||
| 74 | |||||||||||
| 75 | 83 | my @parts; | |||||||||
| 76 | 83 | my $phrase = $self->phrase; | |||||||||
| 77 | 83 | ▶ | push @parts, $format->createPhrase($phrase, @opts) if defined $phrase; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | |||||||||||
| 79 | 83 | my $address = $self->address; | |||||||||
| 80 | 83 | ▶ | push @parts, @parts ? '<'.$address.'>' : $address; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | |||||||||||
| 82 | 83 | my $comment = $self->comment; | |||||||||
| 83 | 83 | ▶ | push @parts, $format->createComment($comment, @opts) if defined $comment; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | |||||||||||
| 85 | 83 | join ' ', @parts; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 23 | 1; | |||||||||