blib/lib/Email/Sender/Transport/SMTP/Persistent.pm

filter: Statementstmt 46.1% 12 / 26 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 3 / 6 Podpod 100% 1 / 1 totaltotal 38.1% 16 / 42 CC 5 SCAR 22.6
CC
5
Cov
35%
_smtp_client
20.0
disconnect
6.0
BEGIN
1.0
CRAP 9.6
« blib/lib/Email/Sender/Transport/SMTP.pm ↑ Summary blib/lib/Email/Sender/Util.pm »
1 package Email::Sender::Transport::SMTP::Persistent 2.603;
2 # ABSTRACT: an SMTP client that stays online
3  
4 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Email::Sender::Transport::SMTP';
6  
7 #pod =head1 DESCRIPTION
8 #pod
9 #pod The stock L<Email::Sender::Transport::SMTP> reconnects each time it sends a
10 #pod message. This transport only reconnects when the existing connection fails.
11 #pod
12 #pod =cut
13  
14 1 ▶use Net::SMTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 has _cached_client => (
17 is => 'rw',
18 );
19  
20 0 ▶sub _smtp_client {
Subroutine _smtp_client: not called CC=4 SCAR=30.0
21 0 my ($self) = @_;
22  
23 0 ▶ if (my $client = $self->_cached_client) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $client = $self->_cached_client) 0 0 0
24 0 ▶ return $client if eval { $client->reset; $client->ok; };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $client->reset; $client->ok } } 0 0 0
25  
26 0 ▶ my $error = $@
Condition0%0/2
$@ || 'error resetting cached SMTP connection: ' . $client->message
l!l
00
MC/DC0%0/1
$@ || 'error resetting cached SMTP connection: ' . $client->message
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
27 || 'error resetting cached SMTP connection: ' . $client->message;
28  
29 0 Carp::carp($error);
30 }
31  
32 0 my $client = $self->SUPER::_smtp_client;
33  
34 0 $self->_cached_client($client);
35  
36 0 return $client;
37 }
38  
39 0 ▶sub _message_complete { }
Subroutine _message_complete: not called CC=1 SCAR=0.0
40  
41 #pod =method disconnect
42 #pod
43 #pod $transport->disconnect;
44 #pod
45 #pod This method sends an SMTP QUIT command and destroys the SMTP client, if on
46 #pod exists and is connected.
47 #pod
48 #pod =cut
49  
50 0 ▶sub disconnect {
Subroutine disconnect: not called CC=2 SCAR=17.9
Pod documented
51 0 my ($self) = @_;
52 0 ▶ return unless $self->_cached_client;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_cached_client 0 0 0
53 0 $self->_cached_client->quit;
54 0 $self->_cached_client(undef);
55 }
56  
57 1 ▶no Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 1 1;
59  
60 __END__
« blib/lib/Email/Sender/Transport/SMTP.pm ↑ Summary blib/lib/Email/Sender/Util.pm »