update patch 1
This commit is contained in:
+8
-13
@@ -18,23 +18,18 @@ use Symfony\Component\HttpFoundation\Exception\LogicException;
|
||||
*/
|
||||
class UriSigner
|
||||
{
|
||||
private string $secret;
|
||||
private string $hashParameter;
|
||||
private string $expirationParameter;
|
||||
|
||||
/**
|
||||
* @param string $hashParameter Query string parameter to use
|
||||
* @param string $expirationParameter Query string parameter to use for expiration
|
||||
*/
|
||||
public function __construct(#[\SensitiveParameter] string $secret, string $hashParameter = '_hash', string $expirationParameter = '_expiration')
|
||||
{
|
||||
public function __construct(
|
||||
#[\SensitiveParameter] private string $secret,
|
||||
private string $hashParameter = '_hash',
|
||||
private string $expirationParameter = '_expiration',
|
||||
) {
|
||||
if (!$secret) {
|
||||
throw new \InvalidArgumentException('A non-empty secret is required.');
|
||||
}
|
||||
|
||||
$this->secret = $secret;
|
||||
$this->hashParameter = $hashParameter;
|
||||
$this->expirationParameter = $expirationParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +55,7 @@ class UriSigner
|
||||
}
|
||||
|
||||
if (null !== $expiration && !$expiration instanceof \DateTimeInterface && !$expiration instanceof \DateInterval && !\is_int($expiration)) {
|
||||
throw new \TypeError(sprintf('The second argument of %s() must be an instance of %s or %s, an integer or null (%s given).', __METHOD__, \DateTimeInterface::class, \DateInterval::class, get_debug_type($expiration)));
|
||||
throw new \TypeError(\sprintf('The second argument of %s() must be an instance of %s or %s, an integer or null (%s given).', __METHOD__, \DateTimeInterface::class, \DateInterval::class, get_debug_type($expiration)));
|
||||
}
|
||||
|
||||
$url = parse_url($uri);
|
||||
@@ -71,11 +66,11 @@ class UriSigner
|
||||
}
|
||||
|
||||
if (isset($params[$this->hashParameter])) {
|
||||
throw new LogicException(sprintf('URI query parameter conflict: parameter name "%s" is reserved.', $this->hashParameter));
|
||||
throw new LogicException(\sprintf('URI query parameter conflict: parameter name "%s" is reserved.', $this->hashParameter));
|
||||
}
|
||||
|
||||
if (isset($params[$this->expirationParameter])) {
|
||||
throw new LogicException(sprintf('URI query parameter conflict: parameter name "%s" is reserved.', $this->expirationParameter));
|
||||
throw new LogicException(\sprintf('URI query parameter conflict: parameter name "%s" is reserved.', $this->expirationParameter));
|
||||
}
|
||||
|
||||
if (null !== $expiration) {
|
||||
|
||||
Reference in New Issue
Block a user