Test Failed
Push — master ( 6731a8...287bb0 )
by Hirofumi
08:50
created

JobFlight::abandoned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Shippinno\Job\Application\Messaging;
4
5
use DateTimeImmutable;
6
7
class JobFlight
8
{
9
    /**
10
     * @string
11
     */
12
    private const RESULT_ACKNOWLEDGED = 'acknowledged';
13
14
    /**
15
     * @string
16
     */
17
    private const RESULT_ABANDONED = 'abandoned';
18
19
    /**
20
     * @string
21
     */
22
    private const RESULT_REQUEUED = 'requeued';
23
24
    /**
25
     * @string
26
     */
27
    private const RESULT_REJECTED = 'rejected';
28
29
    /**
30
     * @string
31
     */
32
    private const RESULT_LET_GO = 'let_go';
33
34
    /**
35
     * @var int
36
     */
37
    private $id;
38
39
    /**
40
     * @var int
41
     */
42
    private $jobId;
43
44
    /**
45
     * @var string
46
     */
47
    private $queue;
48
49
    /**
50
     * @var DateTimeImmutable
51
     */
52
    private $departure;
53
54
    /**
55
     * @var null|DateTimeImmutable
56
     */
57
    private $arrival;
58
59
    /**
60
     * @var string|string
61
     */
62
    private $result;
63
64
    /**
65
     * @param int $jobId
66
     * @param string $queue
67
     */
68
    public function __construct(int $jobId, string $queue)
69
    {
70
        $this->jobId = $jobId;
71
        $this->queue = $queue;
72
        $this->departure = new DateTimeImmutable;
73
        $this->arrival = null;
74
        $this->result = null;
75
    }
76
77
    /**
78
     * @return int
79
     */
80
    public function jobId(): int
81
    {
82
        return $this->jobId;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function queue(): string
89
    {
90
        return $this->queue;
91
    }
92
93
    /**
94
     * @return void
95
     */
96
    public function acknowledge(): void
97
    {
98
        $this->arrival = new DateTimeImmutable;
99
        $this->result = self::RESULT_ACKNOWLEDGED;
100
    }
101
102
    /**
103
     * @return void
104
     */
105
    public function abandoned(): void
106
    {
107
        $this->arrival = new DateTimeImmutable;
108
        $this->result = self::RESULT_ABANDONED;
109
    }
110
111
    /**
112
     * @return void
113
     */
114
    public function requeued(): void
115
    {
116
        $this->arrival = new DateTimeImmutable;
117
        $this->result = self::RESULT_REQUEUED;
118
    }
119
120
    /**
121
     * @throws void
122
     */
123
    public function rejected(): void
124
    {
125
        $this->arrival = new DateTimeImmutable;
126
        $this->result = self::RESULT_REJECTED;
127
    }
128
129
    /**
130
     * @return void
131
     */
132
    public function letGo(): void
133
    {
134
        $this->arrival = new DateTimeImmutable;
135
        $this->result = self::RESULT_LET_GO;
136
    }
137
}
138