Skip to content

Commit e817c85

Browse files
committed
Added laravel pint
1 parent 4e2d883 commit e817c85

File tree

11 files changed

+103
-76
lines changed

11 files changed

+103
-76
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ updates:
1111
- package-ecosystem: composer
1212
directory: "/"
1313
schedule:
14-
interval: monthly
14+
interval: "weekly"
1515
labels:
1616
- dependencies
1717
versioning-strategy: increase-if-necessary
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dependabot-auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v1.3.3
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Auto-merge Dependabot PRs for semver-minor updates
21+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
22+
run: gh pr merge --auto --merge "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
27+
- name: Auto-merge Dependabot PRs for semver-patch updates
28+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Check & fix styling
1+
name: Fix PHP code style issues
22

33
on: [push]
44

55
jobs:
6-
php-cs-fixer:
6+
php-code-styling:
77
runs-on: ubuntu-latest
88

99
steps:
@@ -12,12 +12,13 @@ jobs:
1212
with:
1313
ref: ${{ github.head_ref }}
1414

15-
- name: Run PHP CS Fixer
16-
uses: docker://oskarstark/php-cs-fixer-ga
15+
- name: Fix PHP code style issues
16+
uses: aglipanci/laravel-pint-action@1.0.0
1717
with:
18-
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
18+
preset: laravel
1919

2020
- name: Commit changes
2121
uses: stefanzweifel/git-auto-commit-action@v4
2222
with:
2323
commit_message: Fix styling
24+
skip_fetch: true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v4
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

.php-cs-fixer.dist.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

composer.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"palpalani",
66
"sqs-reader",
77
"sqs-json",
8-
"plain-message",
9-
"bulk-message",
8+
"sqs-text-reader",
9+
"sqs-plain-message",
10+
"sqs-bulk-message",
11+
"laravel-sqs",
1012
"laravel-sqs-queue-json-reader"
1113
],
1214
"homepage": "https://github.com/palpalani/laravel-sqs-queue-json-reader",
@@ -15,7 +17,7 @@
1517
{
1618
"name": "palPalani",
1719
"email": "palani.p@gmail.com",
18-
"homepage": "https://southdreamz.com",
20+
"homepage": "https://github.com/palpalani",
1921
"role": "Developer"
2022
}
2123
],
@@ -28,6 +30,7 @@
2830
"aws/aws-sdk-php": "^3.0"
2931
},
3032
"require-dev": {
33+
"laravel/pint": "^1.1",
3134
"orchestra/testbench": "^6.9|^7.0",
3235
"phpunit/phpunit": "^9.3",
3336
"psalm/plugin-laravel": "^2.0",
@@ -46,7 +49,8 @@
4649
"scripts": {
4750
"psalm": "vendor/bin/psalm",
4851
"test": "./vendor/bin/testbench package:test --parallel --no-coverage",
49-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
52+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
53+
"format": "vendor/bin/pint"
5054
},
5155
"config": {
5256
"sort-packages": true

config/sqs-queue-reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'mailgun-webhooks' => [
1515
'class' => App\Jobs\MailgunHandler::class,
1616
'count' => 100,
17-
]
17+
],
1818
],
1919

2020
// If no handlers specified then default handler will be executed.
@@ -25,5 +25,5 @@
2525

2626
// Number of messages need to read from SQS.
2727
'count' => 1,
28-
]
28+
],
2929
];

src/Jobs/DispatcherJob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getPayload()
3535
}
3636

3737
/**
38-
* @param bool $plain
38+
* @param bool $plain
3939
* @return $this
4040
*/
4141
public function setPlain(bool $plain = true): self

src/Sqs/Queue.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414

1515
/**
1616
* Class CustomSqsQueue
17-
* @package App\Services
1817
*/
1918
class Queue extends SqsQueue
2019
{
2120
/**
2221
* Create a payload string from the given job and data.
2322
*
24-
* @param object|string $job
25-
* @param string $queue
26-
* @param mixed $data
23+
* @param object|string $job
24+
* @param string $queue
25+
* @param mixed $data
2726
* @return string
27+
*
2828
* @throws JsonException
2929
*/
3030
protected function createPayload($job, $queue = null, $data = ''): string
@@ -33,7 +33,7 @@ protected function createPayload($job, $queue = null, $data = ''): string
3333
return parent::createPayload($job, $queue, $data);
3434
}
3535

36-
$handlerJob = $this->getClass($queue) . '@handle';
36+
$handlerJob = $this->getClass($queue).'@handle';
3737

3838
return $job->isPlain() ? \json_encode($job->getPayload(), JSON_THROW_ON_ERROR) : \json_encode([
3939
'job' => $handlerJob,
@@ -62,8 +62,9 @@ private function getClass($queue = null): string
6262
/**
6363
* Pop the next job off of the queue.
6464
*
65-
* @param string $queue
65+
* @param string $queue
6666
* @return \Illuminate\Contracts\Queue\Job|null
67+
*
6768
* @throws JsonException
6869
*/
6970
public function pop($queue = null)
@@ -99,16 +100,17 @@ public function pop($queue = null)
99100
return new SqsJob($this->container, $this->sqs, $response, $this->connectionName, $queue);
100101
}
101102
} catch (AwsException $e) {
102-
$msg = 'Line: '. $e->getLine() .', '. $e->getFile() . ', '. $e->getMessage();
103+
$msg = 'Line: '.$e->getLine().', '.$e->getFile().', '.$e->getMessage();
103104

104-
throw new \RuntimeException("Aws SQS error: " . $msg);
105+
throw new \RuntimeException('Aws SQS error: '.$msg);
105106
}
106107
}
107108

108109
/**
109-
* @param array|string $payload
110-
* @param string $class
110+
* @param array|string $payload
111+
* @param string $class
111112
* @return array|string
113+
*
112114
* @throws JsonException
113115
*/
114116
private function modifySinglePayload(array | string $payload, string $class): array | string
@@ -121,17 +123,18 @@ private function modifySinglePayload(array | string $payload, string $class): ar
121123

122124
$payload['Body'] = \json_encode([
123125
'uuid' => (string) Str::uuid(),
124-
'job' => $class . '@handle',
126+
'job' => $class.'@handle',
125127
'data' => $body['data'] ?? $body,
126128
], JSON_THROW_ON_ERROR);
127129

128130
return $payload;
129131
}
130132

131133
/**
132-
* @param array|string $payload
133-
* @param string $class
134+
* @param array|string $payload
135+
* @param string $class
134136
* @return array
137+
*
135138
* @throws JsonException
136139
*/
137140
private function modifyMultiplePayload(array | string $payload, string $class): array
@@ -170,18 +173,19 @@ private function modifyMultiplePayload(array | string $payload, string $class):
170173
'ReceiptHandle' => $receiptHandle,
171174
'Body' => \json_encode([
172175
'uuid' => (string) Str::uuid(),
173-
'job' => $class . '@handle',
176+
'job' => $class.'@handle',
174177
'data' => $body,
175178
], JSON_THROW_ON_ERROR),
176179
'Attributes' => $attributes,
177180
];
178181
}
179182

180183
/**
181-
* @param string $payload
182-
* @param string|null $queue
183-
* @param array $options
184+
* @param string $payload
185+
* @param string|null $queue
186+
* @param array $options
184187
* @return mixed
188+
*
185189
* @throws JsonException
186190
*/
187191
public function pushRaw($payload, $queue = null, array $options = []): mixed

src/SqsQueueReaderServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function boot(): void
1818
{
1919
if ($this->app->runningInConsole()) {
2020
$this->publishes([
21-
__DIR__ . '/../config/sqs-queue-reader.php' => config_path('sqs-queue-reader.php'),
21+
__DIR__.'/../config/sqs-queue-reader.php' => config_path('sqs-queue-reader.php'),
2222
], 'config');
2323

2424
Queue::after(function (JobProcessed $event) {
@@ -44,7 +44,7 @@ public function boot(): void
4444

4545
public function register(): void
4646
{
47-
$this->mergeConfigFrom(__DIR__ . '/../config/sqs-queue-reader.php', 'sqs-queue-reader');
47+
$this->mergeConfigFrom(__DIR__.'/../config/sqs-queue-reader.php', 'sqs-queue-reader');
4848

4949
$this->app->booted(function () {
5050
$this->app['queue']->extend('sqs-json', static function () {
@@ -80,11 +80,11 @@ private function removeMessages(array $data, $queue): void
8080
if (isset($result['Failed'])) {
8181
$msg = '';
8282
foreach ($result['Failed'] as $failed) {
83-
$msg .= sprintf("Deleting message failed, code = %s, id = %s, msg = %s, senderfault = %s", $failed['Code'], $failed['Id'], $failed['Message'], $failed['SenderFault']);
83+
$msg .= sprintf('Deleting message failed, code = %s, id = %s, msg = %s, senderfault = %s', $failed['Code'], $failed['Id'], $failed['Message'], $failed['SenderFault']);
8484
}
8585
Log::error('Cannot delete some SQS messages: ', [$msg]);
8686

87-
throw new \RuntimeException("Cannot delete some messages, consult log for more info!");
87+
throw new \RuntimeException('Cannot delete some messages, consult log for more info!');
8888
}
8989
//Log::info('Message remove report:', [$result]);
9090
} catch (AwsException $e) {

0 commit comments

Comments
 (0)