Skip to content

Commit d8423c7

Browse files
committed
[TASK] Trying to fix phpstan error
Signed-off-by: Torben Hansen <derhansen@gmail.com>
1 parent 468bb39 commit d8423c7

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

Classes/Service/PwnedPasswordsService.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,22 @@ public function checkPassword(string $password): int
2525
$hash = sha1($password);
2626
$request = GeneralUtility::makeInstance(RequestFactory::class);
2727

28-
try {
29-
$response = $request->request(
30-
'https://api.pwnedpasswords.com/range/' . substr($hash, 0, 5),
31-
'GET',
32-
[
33-
'User-Agent' => 'TYPO3 Extension add_pwd_policies',
34-
]
35-
);
36-
$results = $response->getBody()->getContents();
37-
} catch (\Throwable) {
38-
// Something went wrong with the request, return 0 and ignore check
39-
return 0;
40-
}
28+
$response = $request->request(
29+
'https://api.pwnedpasswords.com/range/' . substr($hash, 0, 5),
30+
'GET',
31+
[
32+
'User-Agent' => 'TYPO3 Extension add_pwd_policies',
33+
]
34+
);
35+
$results = $response->getBody()->getContents();
4136

4237
if (empty($results) || ($response->getStatusCode() !== 200)) {
4338
// Something went wrong with the request, return 0 and ignore check
4439
return 0;
4540
}
4641

4742
if (preg_match('/' . preg_quote(substr($hash, 5)) . ':([0-9]+)/ism', $results, $matches) === 1) {
48-
return (int)$matches[1];
43+
return (int)($matches[1]);
4944
}
5045
return 0;
5146
}

0 commit comments

Comments
 (0)