Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F32474130
D4077.id10763.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4077.id10763.diff
View Options
diff --git a/omnitools/src/HTTP/URL.php b/omnitools/src/HTTP/URL.php
--- a/omnitools/src/HTTP/URL.php
+++ b/omnitools/src/HTTP/URL.php
@@ -5,6 +5,8 @@
use Keruald\OmniTools\Strings\Multibyte\OmniString;
+use Exception;
+
/**
* Represent a URL
*/
@@ -173,22 +175,19 @@
* @see URL::beautifyQuery() for the inverse operation (decode)
*/
public function normalizeQuery (string $query) : string {
- switch ($this->queryEncoding) {
- case self::ENCODE_RFC3986_SLASH_EXCEPTED:
- return (new OmniString($query))
- ->explode("/")
- ->map("rawurlencode")
- ->implode("/")
- ->__toString();
-
- case self::ENCODE_AS_IS:
- return $query;
-
- case self::ENCODE_RFC3986_PURE:
- return rawurlencode($query);
- }
+ return match ($this->queryEncoding) {
+ self::ENCODE_AS_IS => $query,
+
+ self::ENCODE_RFC3986_PURE => rawurlencode($query),
+
+ self::ENCODE_RFC3986_SLASH_EXCEPTED => (new OmniString($query))
+ ->explode("/")
+ ->map("rawurlencode")
+ ->implode("/")
+ ->__toString(),
- throw new \Exception('Unexpected encoding value');
+ default => throw new Exception('Unexpected encoding value'),
+ };
}
/**
@@ -200,22 +199,19 @@
* @see URL::normalizeQuery() for the inverse operation (encode)
*/
public function beautifyQuery (string $query) : string {
- switch ($this->queryEncoding) {
- case self::ENCODE_RFC3986_SLASH_EXCEPTED:
- return (new OmniString($query))
- ->explode("/")
- ->map("rawurldecode")
- ->implode("/")
- ->__toString();
-
- case self::ENCODE_AS_IS:
- return $query;
-
- case self::ENCODE_RFC3986_PURE:
- return rawurldecode($query);
- }
+ return match ($this->queryEncoding) {
+ self::ENCODE_AS_IS => $query,
+
+ self::ENCODE_RFC3986_PURE => rawurldecode($query),
+
+ self::ENCODE_RFC3986_SLASH_EXCEPTED => (new OmniString($query))
+ ->explode("/")
+ ->map("rawurldecode")
+ ->implode("/")
+ ->__toString(),
- throw new \Exception('Unexpected encoding value');
+ default => throw new Exception('Unexpected encoding value'),
+ };
}
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 10, 01:54 (22 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3802486
Default Alt Text
D4077.id10763.diff (2 KB)
Attached To
Mode
D4077: Refactor URL encode/decode
Attached
Detach File
Event Timeline
Log In to Comment