Skip to content

Commit 611ff35

Browse files
author
Greg Bowler
authored
feature: customise query string keys (#36)
1 parent 6b2ad36 commit 611ff35

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/EncryptedUri.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ class EncryptedUri {
1212

1313
public function __construct(
1414
string|UriInterface $uri,
15+
string $cipherQueryStringParameter = "cipher",
16+
string $initVectorStringParameter = "iv",
1517
) {
1618
if(!$uri instanceof UriInterface) {
1719
$uri = new Uri($uri);
1820
}
1921

2022
parse_str($uri->getQuery(), $queryParams);
21-
$cipher = $queryParams["cipher"] ?? null;
22-
$iv = $queryParams["iv"] ?? null;
23+
$cipher = $queryParams[$cipherQueryStringParameter] ?? null;
24+
$iv = $queryParams[$initVectorStringParameter] ?? null;
2325
if(!$cipher || !is_string($cipher)) {
24-
throw new MissingQueryStringException("cipher");
26+
throw new MissingQueryStringException($cipherQueryStringParameter);
2527
}
2628
if(!$iv || !is_string($iv)) {
27-
throw new MissingQueryStringException("iv");
29+
throw new MissingQueryStringException($initVectorStringParameter);
2830
}
2931

3032
$this->encryptedBytes = base64_decode(str_replace(" ", "+", $cipher));

0 commit comments

Comments
 (0)