Skip to content

Commit ce7d5e6

Browse files
committed
small code improvements
1 parent f8d16e2 commit ce7d5e6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function pushRaw($payload, $queue = null, array $options = [])
111111
'delivery_mode' => 2,
112112
];
113113

114-
if (isset($this->attempts) === true) {
114+
if ($this->attempts !== null) {
115115
$headers['application_headers'] = [self::ATTEMPT_COUNT_HEADERS_KEY => ['I', $this->attempts]];
116116
}
117117

@@ -204,7 +204,7 @@ private function declareQueue($name)
204204
$name = $this->getQueueName($name);
205205
$exchange = $this->configExchange['name'] ?: $name;
206206

207-
if ($this->declareExchange && !in_array($exchange, $this->declaredExchanges)) {
207+
if ($this->declareExchange && !in_array($exchange, $this->declaredExchanges, true)) {
208208
// declare exchange
209209
$this->channel->exchange_declare(
210210
$exchange,
@@ -217,7 +217,7 @@ private function declareQueue($name)
217217
$this->declaredExchanges[] = $exchange;
218218
}
219219

220-
if ($this->declareBindQueue && !in_array($name, $this->declaredQueues)) {
220+
if ($this->declareBindQueue && !in_array($name, $this->declaredQueues, true)) {
221221
// declare queue
222222
$this->channel->queue_declare(
223223
$name,
@@ -240,7 +240,7 @@ private function declareQueue($name)
240240
* @param string $destination
241241
* @param DateTime|int $delay
242242
*
243-
* @return string
243+
* @return array
244244
*/
245245
private function declareDelayedQueue($destination, $delay)
246246
{
@@ -251,7 +251,7 @@ private function declareDelayedQueue($destination, $delay)
251251
$exchange = $this->configExchange['name'] ?: $destination;
252252

253253
// declare exchange
254-
if (!in_array($exchange, $this->declaredExchanges)) {
254+
if (!in_array($exchange, $this->declaredExchanges, true)) {
255255
$this->channel->exchange_declare(
256256
$exchange,
257257
$this->configExchange['type'],
@@ -262,7 +262,7 @@ private function declareDelayedQueue($destination, $delay)
262262
}
263263

264264
// declare queue
265-
if (!in_array($name, $this->declaredQueues)) {
265+
if (!in_array($name, $this->declaredQueues, true)) {
266266
$this->channel->queue_declare(
267267
$name,
268268
$this->configQueue['passive'],
@@ -315,7 +315,7 @@ public function setCorrelationId($id)
315315
*/
316316
public function getCorrelationId()
317317
{
318-
return $this->correlationId ?: uniqid();
318+
return $this->correlationId ?: uniqid('', true);
319319
}
320320

321321
/**

tests/RabbitMQQueueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function test_push()
8383

8484
$correlationId = $this->queue->push($job, $data);
8585

86-
$this->assertEquals(13, strlen($correlationId));
86+
$this->assertEquals(23, strlen($correlationId));
8787
}
8888

8989
public function test_later()
@@ -120,7 +120,7 @@ public function test_later()
120120

121121
$correlationId = $this->queue->later($delay, $job, $data);
122122

123-
$this->assertEquals(13, strlen($correlationId));
123+
$this->assertEquals(23, strlen($correlationId));
124124
}
125125

126126
public function test_pop()

0 commit comments

Comments
 (0)