Completed
Push — master ( 9eae13...e56856 )
by Antonio
04:26
created

MailJob   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 11
c 1
b 0
f 1
lcom 3
cbo 1
dl 0
loc 100
ccs 27
cts 27
cp 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isNewRecord() 0 4 1
A getId() 0 4 1
A setId() 0 4 1
A getMessage() 0 4 1
A setMessage() 0 4 1
A getAttempt() 0 4 1
A setAttempt() 0 4 1
A incrementAttempt() 0 4 1
A markAsCompleted() 0 4 1
A isCompleted() 0 4 1
1
<?php
2
namespace Da\Mailer\Model;
3
4
use Da\Mailer\Queue\Backend\MailJobInterface;
5
6
class MailJob extends AbstractMailObject implements MailJobInterface
7
{
8
    /**
9
     * @var mixed
10
     */
11
    private $id;
12
    /**
13
     * @var MailMessage|string
14
     */
15
    private $message;
16
    /**
17
     * @var int number of attempts. Every time a mail fails to be sent, the number of attempts could be incremented.
18
     *
19
     * @see `incrementAttempt()`
20
     */
21
    private $attempt = 0;
22
    /**
23
     * @var bool whether the job has been completed
24
     */
25
    private $completed = false;
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 19
    public function __construct(array $config = [])
31
    {
32 19
        parent::__construct($config);
33 19
    }
34
35
    /**
36
     * @return bool
37
     */
38 15
    public function isNewRecord()
39
    {
40 15
        return $this->getId() === null;
41
    }
42
43
    /**
44
     * @return mixed
45
     */
46 18
    public function getId()
47
    {
48 18
        return $this->id;
49
    }
50
51
    /**
52
     * @param mixed $id
53
     */
54 14
    public function setId($id)
55
    {
56 14
        $this->id = $id;
57 14
    }
58
59
    /**
60
     * @return MailMessage|string
61
     */
62 16
    public function getMessage()
63
    {
64 16
        return $this->message;
65
    }
66
67
    /**
68
     * @param MailMessage|string $message
69
     */
70 19
    public function setMessage($message)
71
    {
72 19
        $this->message = $message;
73 19
    }
74
75
    /**
76
     * @return int
77
     */
78 15
    public function getAttempt()
79
    {
80 15
        return $this->attempt;
81
    }
82
83 14
    public function setAttempt($attempt)
84
    {
85 14
        $this->attempt = $attempt;
86 14
    }
87
88
    /**
89
     * Increments attempt by one.
90
     */
91 1
    public function incrementAttempt()
92
    {
93 1
        $this->attempt += 1;
94 1
    }
95
96 7
    public function markAsCompleted()
97
    {
98 7
        return $this->completed = true;
99
    }
100
101 10
    public function isCompleted()
102
    {
103 10
        return $this->completed === true;
104
    }
105
}
106