MailJob::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Da\Mailer\Model;
4
5
use Da\Mailer\Queue\Backend\MailJobInterface;
6
7
class MailJob extends AbstractMailObject implements MailJobInterface
8
{
9
    /**
10
     * @var mixed
11
     */
12
    private $id;
13
/**
14
     * @var MailMessage|string
15
     */
16
    private $message;
17
/**
18
     * @var int number of attempts. Every time a mail fails to be sent, the number of attempts could be incremented.
19
     *
20
     * @see `incrementAttempt()`
21
     */
22
    private $attempt = 0;
23
/**
24
     * @var bool whether the job has been completed
25
     */
26
    private $completed = false;
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
    /**
84
     * @param $attempt
85
     */
86 14
    public function setAttempt($attempt)
87
    {
88 14
        $this->attempt = $attempt;
89 14
    }
90
91
    /**
92
     * Increments attempt by one.
93
     */
94 1
    public function incrementAttempt()
95
    {
96 1
        $this->attempt += 1;
97 1
    }
98
99
    /**
100
     * @return bool
101
     */
102 7
    public function markAsCompleted()
103
    {
104 7
        return $this->completed = true;
105
    }
106
107
    /**
108
     * @return bool
109
     */
110 10
    public function isCompleted()
111
    {
112 10
        return $this->completed === true;
113
    }
114
}
115