MaxAttemptsReached   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 51
ccs 14
cts 14
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A job() 0 4 1
A maxAttempts() 0 4 1
A exception() 0 4 1
A messageName() 0 4 1
1
<?php
2
3
namespace Zenstruck\Queue\Event;
4
5
use SimpleBus\Message\Name\NamedMessage;
6
use Zenstruck\Queue\Job;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
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 5
    public function __construct(Job $job, $maxAttempts)
21
    {
22 5
        if (!$job->isFailed()) {
23 1
            throw new \LogicException('Job is not marked as failed.');
24
        }
25
26 4
        $this->job = $job;
27 4
        $this->maxAttempts = $maxAttempts;
28 4
    }
29
30
    /**
31
     * @return Job
32
     */
33 2
    public function job()
34
    {
35 2
        return $this->job;
36
    }
37
38
    /**
39
     * @return int
40
     */
41 2
    public function maxAttempts()
42
    {
43 2
        return $this->maxAttempts;
44
    }
45
46
    /**
47
     * @return \Exception
48
     */
49 1
    public function exception()
50
    {
51 1
        return $this->job->failedException();
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public static function messageName()
58
    {
59 1
        return 'queue.max_attempts_reached';
60
    }
61
}
62