Skip to content

Commit 4d941f1

Browse files
authored
Merge pull request #11 from PiteurStudio/refactor
Refactor
2 parents 2393da4 + 37e3e0b commit 4d941f1

File tree

8 files changed

+10
-64
lines changed

8 files changed

+10
-64
lines changed

.editorconfig

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

.github/workflows/dependabot-auto-merge.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ yarn-error.log
1818
/.idea
1919
/.fleet
2020
/.vscode
21+
.editorconfig
2122

2223
# Code sniffer
2324
.php_cs

rector.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@
99
__DIR__.'/src',
1010
__DIR__.'/tests',
1111
])
12-
// uncomment to reach your current PHP version
13-
// ->withPhpSets()
14-
->withTypeCoverageLevel(0)
15-
->withDeadCodeLevel(0)
16-
->withCodeQualityLevel(0);
12+
->withPhpSets();

src/Client/HttpClientService.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ class HttpClientService
2626

2727
private bool $verifySsl = false;
2828

29-
private bool $test_mode;
30-
31-
private HttpClientInterface $httpClient;
29+
private readonly HttpClientInterface $httpClient;
3230

3331
/**
3432
* @param bool $test_mode Whether to use the test API or not.
3533
* @param HttpClientInterface|null $httpClient Injected HTTP client for testing (optional).
3634
*/
37-
public function __construct(bool $test_mode = false, ?HttpClientInterface $httpClient = null)
35+
public function __construct(private readonly bool $test_mode = false, ?HttpClientInterface $httpClient = null)
3836
{
39-
$this->test_mode = $test_mode;
4037
$this->httpClient = $httpClient ?? new RetryableHttpClient(HttpClient::create($this->getClientOptions()), null, $this->maxRetries);
4138
}
4239

src/SatimConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ abstract class SatimConfig
6464
*
6565
* @var non-empty-string|null
6666
*/
67-
protected ?string $failUrl;
67+
protected ?string $failUrl = null;
6868

6969
/**
7070
* The URL to redirect to after the payment is processed.

src/SatimStatusChecker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function isRejected(): bool
6464
return false;
6565
}
6666

67-
if (! empty($response['ErrorMessage']) && str_contains($response['ErrorMessage'], 'Payment is declined')) {
67+
if (! empty($response['ErrorMessage']) && str_contains((string) $response['ErrorMessage'], 'Payment is declined')) {
6868
return true;
6969
}
7070

@@ -154,7 +154,7 @@ public function isCancelled(): bool
154154
return false;
155155
}
156156

157-
if (! empty($this->getResponse()['ErrorMessage']) && str_contains($this->getResponse()['ErrorMessage'], 'Payment is cancelled')) {
157+
if (! empty($this->getResponse()['ErrorMessage']) && str_contains((string) $this->getResponse()['ErrorMessage'], 'Payment is cancelled')) {
158158
return true;
159159
}
160160

tests/Unit/SatimTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
$requestData = $method->invoke($this->satim);
131131

132132
// Decode JSON `jsonParams`
133-
$jsonParams = json_decode($requestData['jsonParams'], true);
133+
$jsonParams = json_decode((string) $requestData['jsonParams'], true);
134134

135135
expect($jsonParams)->toHaveKeys(['force_terminal_id', 'custom_field_1', 'custom_field_2'])
136136
->and($jsonParams['force_terminal_id'])->toBe('123456')
@@ -157,7 +157,7 @@
157157
$requestData = $method->invoke($this->satim);
158158

159159
// Decode JSON `jsonParams`
160-
$jsonParams = json_decode($requestData['jsonParams'], true);
160+
$jsonParams = json_decode((string) $requestData['jsonParams'], true);
161161

162162
expect($jsonParams)->toHaveKey('force_terminal_id')
163163
->and($jsonParams)->not()->toHaveKeys(['custom_field_1', 'custom_field_2']);
@@ -185,7 +185,7 @@
185185
$requestData = $method->invoke($this->satim);
186186

187187
// Decode JSON `jsonParams`
188-
$jsonParams = json_decode($requestData['jsonParams'], true);
188+
$jsonParams = json_decode((string) $requestData['jsonParams'], true);
189189

190190
expect($jsonParams)->toHaveKey('force_terminal_id')
191191
->and($jsonParams['force_terminal_id'])->toBe('OVERWRITTEN_VALUE')

0 commit comments

Comments
 (0)