Test Failed
Push — master ( 7d30ec...97ddd4 )
by Hirofumi
02:25
created

JobFlight::arrive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
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 $jobName;
48
49
    /**
50
     * @var string
51
     */
52
    private $queue;
53
54
    /**
55
     * @var DateTimeImmutable
56
     */
57
    private $creation;
58
59
    /**
60
     * @var null|DateTimeImmutable
61
     */
62
    private $boarding;
63
64
    /**
65
     * @var null|DateTimeImmutable
66
     */
67
    private $departure;
68
69
    /**
70
     * @var null|DateTimeImmutable
71
     */
72
    private $arrival;
73
74
    /**
75
     * @var null|DateTimeImmutable
76
     */
77
    private $immigration;
78
79
    /**
80
     * @var string|string
81
     */
82
    private $result;
83
84
    /**
85
     * @param int $jobId
86
     * @param string $jobName
87
     * @param string $queue
88
     */
89
    public function __construct(int $jobId, string $jobName, string $queue)
90
    {
91
        $this->jobId = $jobId;
92
        $this->jobName = $jobName;
93
        $this->queue = $queue;
94
        $this->creation = $this->now();
95
        $this->boarding = null;
96
        $this->departure = null;
97
        $this->arrival = null;
98
        $this->immigration = null;
99
        $this->result = null;
100
    }
101
102
    /**
103
     * @return int
104
     */
105
    public function jobId(): int
106
    {
107
        return $this->jobId;
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    public function jobName(): string
114
    {
115
        return $this->jobName;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function queue(): string
122
    {
123
        return $this->queue;
124
    }
125
126
    /**
127
     * @return void
128
     */
129
    public function board(): void
130
    {
131
        $this->boarding = $this->now();
132
    }
133
134
    /**
135
     * @return void
136
     */
137
    public function depart(): void
138
    {
139
        $this->departure = $this->now();
140
    }
141
142
    /**
143
     * @return void
144
     */
145
    public function arrive(): void
146
    {
147
        $this->arrival = $this->now();
148
    }
149
150
    /**
151
     * @return void
152
     */
153
    public function acknowledge(): void
154
    {
155
        $this->immigration = $this->now();
156
        $this->result = self::RESULT_ACKNOWLEDGED;
157
    }
158
159
    /**
160
     * @return void
161
     */
162
    public function abandoned(): void
163
    {
164
        $this->immigration = $this->now();
165
        $this->result = self::RESULT_ABANDONED;
166
    }
167
168
    /**
169
     * @return void
170
     */
171
    public function requeued(): void
172
    {
173
        $this->immigration = $this->now();
174
        $this->result = self::RESULT_REQUEUED;
175
    }
176
177
    /**
178
     * @return void
179
     */
180
    public function rejected(): void
181
    {
182
        $this->immigration = $this->now();
183
        $this->result = self::RESULT_REJECTED;
184
    }
185
186
    /**
187
     * @return void
188
     */
189
    public function letGo(): void
190
    {
191
        $this->immigration = $this->now();
192
        $this->result = self::RESULT_LET_GO;
193
    }
194
195
    /**
196
     * @return DateTimeImmutable
197
     */
198
    protected function now(): DateTimeImmutable
199
    {
200
        return new DateTimeImmutable;
201
    }
202
}
203