Various code cleanup.

This commit is contained in:
James Cole
2021-04-06 17:00:16 +02:00
parent 8572280b7b
commit 38d0f0427f
61 changed files with 419 additions and 369 deletions

View File

@@ -22,9 +22,9 @@ declare(strict_types=1);
namespace FireflyIII\Services\Password;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use Log;
use RuntimeException;
@@ -51,7 +51,7 @@ class PwndVerifierV2 implements Verifier
$uri = sprintf('https://api.pwnedpasswords.com/range/%s', $prefix);
$opt = [
'headers' => [
'User-Agent' => 'Firefly III v' . config('firefly.version'),
'User-Agent' => sprintf('Firefly III v%s', config('firefly.version')),
'Add-Padding' => 'true',
],
'timeout' => 3.1415];
@@ -62,7 +62,7 @@ class PwndVerifierV2 implements Verifier
try {
$client = new Client();
$res = $client->request('GET', $uri, $opt);
} catch (GuzzleException | Exception $e) {
} catch (GuzzleException | RequestException $e) {
Log::error(sprintf('Could not verify password security: %s', $e->getMessage()));
return true;
@@ -73,7 +73,7 @@ class PwndVerifierV2 implements Verifier
}
try {
$strpos = stripos($res->getBody()->getContents(), $rest);
} catch (RuntimeException $e) {
} catch (RuntimeException $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not get body from Pwnd result: %s', $e->getMessage()));
$strpos = false;
}