| 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::AddrGroup;{ | ||||||||||||||
| 13 | 28 | our $VERSION = '4.05'; | |||||||||||||
| 14 | } | ||||||||||||||
| 15 | |||||||||||||||
| 16 | 28 | ▶ | use parent 'User::Identity::Collection::Emails'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | |||||||||||||||
| 18 | 28 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 28 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | 28 | ▶ | use Log::Report 'mail-message', import => [ qw/__x error/ ]; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 22 | |||||||||||||||
| 23 | 28 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | #-------------------- | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 28 | ▶ | use overload '""' => 'string'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 28 | |||||||||||||||
| 29 | #-------------------- | ||||||||||||||
| 30 | |||||||||||||||
| 31 | sub string() | ||||||||||||||
| 32 | 16 | ▶ | { my $self = shift; | ||||||||||||
|
Subroutine
string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 33 | 16 | my $name = $self->name; | |||||||||||||
| 34 | 16 | my @addr = sort map $_->string, $self->addresses; | |||||||||||||
| 35 | |||||||||||||||
| 36 | 16 | local $" = ', '; | |||||||||||||
| 37 | 16 | ▶ | length $name ? "$name: @addr;" : @addr ? "@addr" : ''; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 38 | } | ||||||||||||||
| 39 | |||||||||||||||
| 40 | #-------------------- | ||||||||||||||
| 41 | |||||||||||||||
| 42 | sub coerce($@) | ||||||||||||||
| 43 | 1 | ▶ | { my ($class, $addr, %args) = @_; | ||||||||||||
|
Subroutine
coerce: called CC=6 SCAR=22.0
Pod
documented
| |||||||||||||||
| 44 | 1 | ▶ | defined $addr or return (); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | |||||||||||||||
| 46 | 1 | ▶ | if(blessed $addr) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | 1 | ▶ | { return $addr if $addr->isa($class); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | |||||||||||||||
| 49 | 1 | ▶ | return bless $addr, $class | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | if $addr->isa('User::Identity::Collection::Emails'); | ||||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | 0 | ▶ | error __x"cannot coerce a {type} into a {class}.", type => ref $addr // 'string', class => $class; | ||||||||||||
|
Condition0%0/2
ref $addr // "string"
MC/DC0%0/1
ref $addr // "string"
ref $addr
Truth table0%0/2
A
A= ref $addr
| |||||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | |||||||||||||||
| 57 | #-------------------- | ||||||||||||||
| 58 | |||||||||||||||
| 59 | sub addAddress(@) | ||||||||||||||
| 60 | 45 | ▶ | { my $self = shift; | ||||||||||||
|
Subroutine
addAddress: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||
| 61 | |||||||||||||||
| 62 | 45 | ▶ | my $addr | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 63 | = @_ > 1 ? Mail::Message::Field::Address->new(@_) | ||||||||||||||
| 64 | : !$_[0] ? return () | ||||||||||||||
| 65 | : Mail::Message::Field::Address->coerce(shift); | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 45 | $self->addRole($addr); | |||||||||||||
| 68 | 45 | $addr; | |||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | |||||||||||||||
| 72 | # roles are stored in a hash, so produce | ||||||||||||||
| 73 | 59 | ▶ | sub addresses() { $_[0]->roles } | ||||||||||||
|
Subroutine
addresses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 74 | |||||||||||||||
| 75 | #-------------------- | ||||||||||||||
| 76 | |||||||||||||||
| 77 | 28 | 1; | |||||||||||||