[SecureRandom] ignore coverage for entropy exceptions

This commit is contained in:
azjezz 2020-08-17 22:34:22 +01:00
parent b36885ecd0
commit ed747fb5e8
2 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,7 @@ function bytes(int $length): string
try {
return \random_bytes($length);
// @codeCoverageIgnoreStart
} catch (\Exception $e) {
$code = $e->getCode();
if (Str\is_string($code)) {
@ -29,5 +30,6 @@ function bytes(int $length): string
}
throw new Psl\Exception\RuntimeException('Unable to gather sufficient entropy.', $code, $e);
// @codeCoverageIgnoreEnd
}
}

View File

@ -20,6 +20,7 @@ function int(int $min = Math\INT64_MIN, int $max = Math\INT64_MAX): int
try {
return \random_int($min, $max);
// @codeCoverageIgnoreStart
} catch (\Exception $e) {
$code = $e->getCode();
if (Str\is_string($code)) {
@ -27,5 +28,6 @@ function int(int $min = Math\INT64_MIN, int $max = Math\INT64_MAX): int
}
throw new Psl\Exception\RuntimeException('Unable to gather sufficient entropy.', $code, $e);
// @codeCoverageIgnoreEnd
}
}