Skip to content

Commit d7b7776

Browse files
committed
cs and analysis update
1 parent 11558e3 commit d7b7776

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎config/autoload/ip-address.global.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
65
// @see https://github.com/akrabat/ip-address-middleware/blob/main/src/IpAddress.php
76
return [
87
'rka' => [

‎src/App/src/Service/ContactService.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function turnstileSiteKey(): string
7979
return $this->turnstile['secret_key'] !== '' ? $this->turnstile['site_key'] : '';
8080
}
8181

82-
public function verifyTurnstile(string $token, ?string $remoteIp): bool
82+
public function verifyTurnstile(string $token, string $remoteIp): bool
8383
{
8484
if ($this->turnstileSiteKey() === '') {
8585
return true;
@@ -93,7 +93,7 @@ public function verifyTurnstile(string $token, ?string $remoteIp): bool
9393
'secret' => $this->turnstile['secret_key'],
9494
'response' => $token,
9595
];
96-
if ($remoteIp) {
96+
if ($remoteIp !== '') {
9797
$data['remoteip'] = $remoteIp;
9898
}
9999

@@ -176,7 +176,7 @@ public function validate(array $data): array
176176
/**
177177
* @param ContactData $data
178178
*/
179-
public function send(array $data, ?string $ipAddress = null): bool
179+
public function send(array $data, string $ipAddress = ''): bool
180180
{
181181
$this->mailService->getMessage()->setReplyTo($data['email'], $data['name']);
182182
$this->mailService->setSubject('New contact form submission on dotkernel.com');
@@ -237,7 +237,7 @@ private function stringValue(array $raw, string $key): string
237237
/**
238238
* @param ContactData $data
239239
*/
240-
private function buildBody(array $data, ?string $ipAddress): string
240+
private function buildBody(array $data, string $ipAddress): string
241241
{
242242
$rows = [
243243
'Topic' => ContactTopicEnum::tryFrom($data['topic'])?->label() ?? '',

‎test/Unit/App/Service/ContactServiceTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function testTurnstileIsOffWithEmptyKeys(): void
391391
);
392392

393393
$this->assertSame('', $service->turnstileSiteKey());
394-
$this->assertTrue($service->verifyTurnstile('', null));
394+
$this->assertTrue($service->verifyTurnstile('', ''));
395395
$this->assertSame([], $calls);
396396
}
397397

@@ -405,14 +405,14 @@ public function testTurnstileIsOffWithoutASecretKey(): void
405405
);
406406

407407
$this->assertSame('', $service->turnstileSiteKey());
408-
$this->assertTrue($service->verifyTurnstile('', null));
408+
$this->assertTrue($service->verifyTurnstile('', ''));
409409
$this->assertSame([], $calls);
410410
}
411411

412412
public function testTurnstileIsOffByDefault(): void
413413
{
414414
$this->assertSame('', $this->service()->turnstileSiteKey());
415-
$this->assertTrue($this->service()->verifyTurnstile('', null));
415+
$this->assertTrue($this->service()->verifyTurnstile('', ''));
416416
}
417417

418418
public function testTurnstileSiteKeyIsExposedWhenBothKeysAreSet(): void
@@ -449,7 +449,7 @@ public function testRemoteIpIsOmittedWhenNull(): void
449449
$calls = [];
450450
$service = $this->turnstileService(self::TURNSTILE, self::SITEVERIFY_SUCCESS, $calls);
451451

452-
$this->assertTrue($service->verifyTurnstile('token', null));
452+
$this->assertTrue($service->verifyTurnstile('token', ''));
453453
$this->assertSame([['secret' => 'secret-key', 'response' => 'token']], $calls);
454454
}
455455

@@ -476,7 +476,7 @@ public static function rejectedSiteverifyProvider(): array
476476
#[DataProvider('rejectedSiteverifyProvider')]
477477
public function testRejectedSiteverifyFails(array $turnstile, ?string $response): void
478478
{
479-
$this->assertFalse($this->turnstileService($turnstile, $response)->verifyTurnstile('token', null));
479+
$this->assertFalse($this->turnstileService($turnstile, $response)->verifyTurnstile('token', ''));
480480
}
481481

482482
public function testMatchingHostnamePasses(): void
@@ -486,7 +486,7 @@ public function testMatchingHostnamePasses(): void
486486
self::SITEVERIFY_SUCCESS
487487
);
488488

489-
$this->assertTrue($service->verifyTurnstile('token', null));
489+
$this->assertTrue($service->verifyTurnstile('token', ''));
490490
}
491491

492492
public function testTestingKeyResponsePassesEvenWithAHostnameConfigured(): void
@@ -496,6 +496,6 @@ public function testTestingKeyResponsePassesEvenWithAHostnameConfigured(): void
496496
'{"success":true,"hostname":"example.com","metadata":{"result_with_testing_key":true}}'
497497
);
498498

499-
$this->assertTrue($service->verifyTurnstile('token', null));
499+
$this->assertTrue($service->verifyTurnstile('token', ''));
500500
}
501501
}

0 commit comments

Comments
 (0)