Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 0 |
1 | <?php |
||
33 | 3 | public function execute(Email $email, int $maxAttempts = 1, SmtpConfiguration $smtpConfiguration = null): int |
|
34 | { |
||
35 | 3 | for ($i = 1; $i <= $maxAttempts; $i++) { |
|
36 | try { |
||
37 | 3 | return $this->doExecute($email, $smtpConfiguration); |
|
38 | 2 | } catch (EmailNotSentException|Throwable $e) { |
|
39 | 2 | if ($i < $maxAttempts) { |
|
40 | 1 | continue; |
|
41 | } |
||
42 | 2 | $this->logger->debug(sprintf('Gave up sending an email after reattempting %d times.', $i), [ |
|
43 | 2 | 'subject' => $email->subject(), |
|
44 | 2 | 'exception' => $e, |
|
45 | ]); |
||
46 | 2 | throw $e; |
|
47 | } |
||
48 | } |
||
49 | } |
||
50 | |||
59 |