Skip to content

Commit 26b8cf4

Browse files
authored
Merge pull request #5 from stof/improve_cs
Improve the php-cs-fixer configuration
2 parents 0647b69 + 3d23e7d commit 26b8cf4

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

.cache/generate/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.cache/php-cs-fixer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ jobs:
2929
run: composer update --ansi --no-progress --prefer-dist --no-interaction
3030
- run: vendor/bin/phpstan analyze
3131

32+
coding_standards:
33+
name: Coding standards
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v3
37+
- uses: shivammathur/setup-php@v2
38+
with:
39+
coverage: none
40+
php-version: '8.1'
41+
- name: Install dependencies
42+
run: composer update --ansi --no-progress --prefer-dist --no-interaction
43+
- run: vendor/bin/php-cs-fixer fix --dry-run --show-progress=dots --no-interaction
44+
3245
tests:
3346
name: "Tests on PHP ${{ matrix.php }}${{ matrix.name_suffix }}"
3447
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/vendor/
22
/composer.lock
33
/phpunit.xml
4-
*.cache
4+
/.phpunit.result.cache

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
'ordered_class_elements' => ['sort_algorithm' => 'none'],
8484
'class_attributes_separation' => ['elements' => ['property' => 'one', 'method' => 'one']],
8585
'array_indentation' => true,
86+
'ternary_to_null_coalescing' => true,
8687
])
8788
->setFinder($finder)
8889
;

src/ValueObject/CardInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class CardInfo
2525
public function __construct(array $input)
2626
{
2727
$this->value = isset($input['value']) ? MoneyAmount::create($input['value']) : $this->throwException(new InvalidArgument('Missing required field "value".'));
28-
$this->cardStatus = isset($input['cardStatus']) ? $input['cardStatus'] : $this->throwException(new InvalidArgument('Missing required field "cardStatus".'));
28+
$this->cardStatus = $input['cardStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "cardStatus".'));
2929
}
3030

3131
/**

src/ValueObject/MoneyAmount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ final class MoneyAmount
2525
*/
2626
public function __construct(array $input)
2727
{
28-
$this->amount = isset($input['amount']) ? $input['amount'] : $this->throwException(new InvalidArgument('Missing required field "amount".'));
29-
$this->currencyCode = isset($input['currencyCode']) ? $input['currencyCode'] : $this->throwException(new InvalidArgument('Missing required field "currencyCode".'));
28+
$this->amount = $input['amount'] ?? $this->throwException(new InvalidArgument('Missing required field "amount".'));
29+
$this->currencyCode = $input['currencyCode'] ?? $this->throwException(new InvalidArgument('Missing required field "currencyCode".'));
3030
}
3131

3232
/**

tests/Integration/AmazonIncentivesClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testGetAvailableFunds(): void
115115

116116
private function getClient(): AmazonIncentivesClient
117117
{
118-
if (!isset($_SERVER['AMAZON_INCENTIVES_ACCESS_KEY'], $_SERVER['AMAZON_INCENTIVES_SECRET_KEY']) || $_SERVER['AMAZON_INCENTIVES_ACCESS_KEY'] === '' || $_SERVER['AMAZON_INCENTIVES_SECRET_KEY'] === '') {
118+
if (!isset($_SERVER['AMAZON_INCENTIVES_ACCESS_KEY'], $_SERVER['AMAZON_INCENTIVES_SECRET_KEY']) || '' === $_SERVER['AMAZON_INCENTIVES_ACCESS_KEY'] || '' === $_SERVER['AMAZON_INCENTIVES_SECRET_KEY']) {
119119
self::markTestSkipped('Test credentials are not provided.');
120120
}
121121

@@ -126,7 +126,7 @@ private function getClient(): AmazonIncentivesClient
126126

127127
private function getPartnerId(): string
128128
{
129-
if (!isset($_SERVER['AMAZON_INCENTIVES_PARTNER_ID']) || $_SERVER['AMAZON_INCENTIVES_PARTNER_ID'] === '') {
129+
if (!isset($_SERVER['AMAZON_INCENTIVES_PARTNER_ID']) || '' === $_SERVER['AMAZON_INCENTIVES_PARTNER_ID']) {
130130
self::markTestSkipped('Test credentials are not provided.');
131131
}
132132

0 commit comments

Comments
 (0)