Skip to content

Commit c7c37a2

Browse files
committed
fix style
1 parent e248447 commit c7c37a2

File tree

8 files changed

+37
-52
lines changed

8 files changed

+37
-52
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
run:
1111
runs-on: 'ubuntu-latest'
1212
strategy:
13-
fail-fast: true
13+
fail-fast: false
1414
matrix:
15-
php: ['8.1']
15+
php: ['8.1', '8.2']
1616
stability: [prefer-stable]
1717

1818
services:

phpcs.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0"?>
22
<ruleset name="PHP_CodeSniffer">
33
<description>The coding standard for our project.</description>
4-
<file>src</file>
5-
64
<rule ref="PSR12"/>
75

6+
<file>src</file>
7+
<file>tests</file>
8+
89

910
<!-- Show progression -->
1011
<arg value="p"/>
11-
<arg name="extensions" value="php"/>
1212

1313
<rule ref="PSR12">
1414
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>

src/Connectors/RabbitMQConnector.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class RabbitMQConnector implements ConnectorInterface
1414
{
1515
public function __construct(private readonly Dispatcher $dispatcher)
1616
{
17-
}//end __construct()
18-
17+
}
1918

2019
public function connect(array $config = []): Queue
2120
{
@@ -48,5 +47,5 @@ public function connect(array $config = []): Queue
4847
$this->dispatcher->listen(WorkerStopping::class, fn() => $rabbitQueue->close());
4948

5049
return $rabbitQueue;
51-
}//end connect()
52-
}//end class
50+
}
51+
}

src/Console/ConsumeCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public function handle(): void
5050
$consumer->setPrefetchCount((int) $this->option('prefetch-count'));
5151

5252
parent::handle();
53-
}//end handle()
54-
53+
}
5554

5655
private function consumerTag(): string
5756
{
@@ -69,5 +68,5 @@ private function consumerTag(): string
6968
);
7069

7170
return Str::substr($consumerTag, 0, 255);
72-
}//end consumerTag()
73-
}//end class
71+
}
72+
}

src/Consumer.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,29 @@ class Consumer extends Worker
3232
public function setContainer(Container $container): void
3333
{
3434
$this->container = $container;
35-
}//end setContainer()
36-
35+
}
3736

3837
public function setConsumerTag(string $value): void
3938
{
4039
$this->consumerTag = $value;
41-
}//end setConsumerTag()
42-
40+
}
4341

4442
public function setMaxPriority(int $value): void
4543
{
4644
$this->maxPriority = $value;
47-
}//end setMaxPriority()
45+
}
4846

4947

5048
public function setPrefetchSize(int $value): void
5149
{
5250
$this->prefetchSize = $value;
53-
}//end setPrefetchSize()
51+
}
5452

5553

5654
public function setPrefetchCount(int $value): void
5755
{
5856
$this->prefetchCount = $value;
59-
}//end setPrefetchCount()
57+
}
6058

6159

6260
/**
@@ -175,9 +173,8 @@ function (AMQPMessage $amqpMessage) use ($connection, $workerOptions, $connectio
175173
}
176174

177175
$this->currentJob = null;
178-
}//end while
179-
}//end daemon()
180-
176+
}
177+
}
181178

182179
/**
183180
* Determine if the daemon should process on this iteration.
@@ -188,7 +185,7 @@ function (AMQPMessage $amqpMessage) use ($connection, $workerOptions, $connectio
188185
protected function daemonShouldRun(WorkerOptions $workerOptions, $connectionName, $queue): bool
189186
{
190187
return !(($this->isDownForMaintenance)() && ! $workerOptions->force) && !$this->paused;
191-
}//end daemonShouldRun()
188+
}
192189

193190

194191
public function stop($status = 0, $options = []): int
@@ -198,5 +195,5 @@ public function stop($status = 0, $options = []): int
198195
$this->amqpChannel->basic_cancel($this->consumerTag, false, true);
199196

200197
return parent::stop($status);
201-
}//end stop()
202-
}//end class
198+
}
199+
}

src/Jobs/RabbitMQJob.php

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,23 @@ public function __construct(
2929
$this->connectionName = $connectionName;
3030
$this->queue = $queue;
3131
$this->decoded = $this->payload();
32-
}//end __construct()
33-
32+
}
3433

3534
/**
3635
* {@inheritdoc}
3736
*/
3837
public function getJobId()
3938
{
4039
return $this->decoded['id'] ?? null;
41-
}//end getJobId()
42-
40+
}
4341

4442
/**
4543
* {@inheritdoc}
4644
*/
4745
public function getRawBody(): string
4846
{
4947
return $this->amqpMessage->getBody();
50-
}//end getRawBody()
51-
48+
}
5249

5350
/**
5451
* {@inheritdoc}
@@ -62,7 +59,7 @@ public function attempts(): int
6259
$laravelAttempts = (int) Arr::get($rabbitMQMessageHeaders, 'laravel.attempts', 0);
6360

6461
return ($laravelAttempts + 1);
65-
}//end attempts()
62+
}
6663

6764

6865
private function convertMessageToFailed(): void
@@ -71,8 +68,7 @@ private function convertMessageToFailed(): void
7168
$this->rabbitQueue->declareQueue('failed_messages');
7269
$this->rabbitQueue->pushRaw($this->amqpMessage->getBody(), 'failed_messages');
7370
}
74-
}//end convertMessageToFailed()
75-
71+
}
7672

7773
/**
7874
* {@inheritdoc}
@@ -87,8 +83,7 @@ public function markAsFailed(): void
8783
$this->rabbitQueue->reject($this);
8884

8985
$this->convertMessageToFailed();
90-
}//end markAsFailed()
91-
86+
}
9287

9388
/**
9489
* {@inheritdoc}
@@ -102,8 +97,7 @@ public function delete(): void
10297
if (! $this->failed) {
10398
$this->rabbitQueue->ack($this);
10499
}
105-
}//end delete()
106-
100+
}
107101

108102
/**
109103
* Release the job back into the queue.
@@ -123,20 +117,17 @@ public function release($delay = 0): void
123117
// Because this Job message is always recreated and pushed as new message, this Job message is correctly handled.
124118
// We must tell rabbitMQ this job message can be removed by acknowledging the message.
125119
$this->rabbitQueue->ack($this);
126-
}//end release()
127-
120+
}
128121

129122
public function getRabbitMQ(): RabbitQueue
130123
{
131124
return $this->rabbitQueue;
132-
}//end getRabbitMQ()
133-
125+
}
134126

135127
public function getRabbitMQMessage(): AMQPMessage
136128
{
137129
return $this->amqpMessage;
138-
}//end getRabbitMQMessage()
139-
130+
}
140131

141132
private function getRabbitMQMessageHeaders(): ?array
142133
{
@@ -148,5 +139,5 @@ private function getRabbitMQMessageHeaders(): ?array
148139
}
149140

150141
return $headers->getNativeData();
151-
}//end getRabbitMQMessageHeaders()
152-
}//end class
142+
}
143+
}

src/LaravelRabbitQueueServiceProvider.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ function (): \iamfarhad\LaravelRabbitMQ\Consumer {
4646
]
4747
);
4848
}//end if
49-
}//end register()
50-
49+
}
5150

5251
public function boot(): void
5352
{
@@ -57,5 +56,5 @@ public function boot(): void
5756
$queue = $this->app['queue'];
5857

5958
$queue->addConnector('rabbitmq', fn(): \iamfarhad\LaravelRabbitMQ\Connectors\RabbitMQConnector => new RabbitMQConnector($this->app['events']));
60-
}//end boot()
61-
}//end class
59+
}
60+
}

src/RabbitQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function pop($queue = null)
136136
);
137137
}
138138
} catch (AMQPProtocolChannelException $amqpProtocolChannelException) {
139-
// If there is not exchange or queue AMQP will throw exception with code 404
139+
// If there is no exchange or queue AMQP will throw exception with code 404
140140
// We need to catch it and return null
141141
if ($amqpProtocolChannelException->amqp_reply_code === 404) {
142142
// Because of the channel exception the channel was closed and removed.

0 commit comments

Comments
 (0)