Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
RetryTrait 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 canRetry 100.00% 1 / 1 100.00% 1 / 1 1
 maxRetry 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\Hermes\Handler;
6
7use Throwable;
8use Tomaj\Hermes\MessageInterface;
9
10/**
11 * Default retry policy: retry every failure, at most 25 times.
12 *
13 * Use it in a class that implements RetryableHandlerInterface. A handler that uses the trait
14 * without the interface is retried as well.
15 */
16trait RetryTrait
17{
18    public function canRetry(MessageInterface $message, Throwable $exception): bool
19    {
20        return true;
21    }
22
23    public function maxRetry(): int
24    {
25        return 25;
26    }
27}