| 1 | <?php |
||
| 11 | final class MaxAttemptsReached implements NamedMessage |
||
| 12 | { |
||
| 13 | private $job; |
||
| 14 | private $maxAttempts; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param Job $job |
||
| 18 | * @param int $maxAttempts |
||
| 19 | */ |
||
| 20 | 4 | public function __construct(Job $job, $maxAttempts) |
|
| 21 | { |
||
| 22 | if (!$job->isFailed()) { |
||
| 23 | throw new \LogicException('Job is not marked as failed.'); |
||
| 24 | } |
||
| 25 | |||
| 26 | 4 | $this->job = $job; |
|
| 27 | 4 | $this->maxAttempts = $maxAttempts; |
|
| 28 | 1 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @return Job |
||
| 32 | */ |
||
| 33 | 2 | public function job() |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @return int |
||
| 40 | */ |
||
| 41 | 2 | public function maxAttempts() |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @return \Exception |
||
| 48 | */ |
||
| 49 | public function exception() |
||
| 50 | { |
||
| 51 | return $this->job->failedException(); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | 1 | public static function messageName() |
|
| 61 | } |
||
| 62 |