diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1da4204..0bf9070 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,8 +3,8 @@
-
-
+
+
@@ -18,11 +18,23 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -31,8 +43,8 @@
-
-
+
+
@@ -42,8 +54,8 @@
-
-
+
+
@@ -57,20 +69,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -87,8 +90,20 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -102,28 +117,13 @@
-
-
-
-
-
-
-
-
-
- findRoute
- ->fireEvents
- RENDER_MIDD
- EVENT_RENDER_CSRF
- RENDER_ROUTE
requirements
# Advan
# Feed
- : void
call_user_func_array
loadClass
$this->
@@ -145,6 +145,12 @@
setSize
helpers.php
getName
+ url(
+ url()
+ : void
+ void
+ set
+ hasParam
D:\Workspace\simple-php-router\src\Pecee\SimpleRouter\Route
@@ -205,18 +211,18 @@
-
-
-
+
+
+
@@ -276,9 +282,8 @@
-
-
-
+
+
@@ -290,6 +295,7 @@
+
@@ -376,7 +382,6 @@
-
@@ -389,7 +394,7 @@
-
+
@@ -512,7 +517,10 @@
-
+
+
+
+
@@ -549,7 +557,7 @@
-
+
@@ -561,30 +569,31 @@
-
-
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
-
-
+
-
-
+
+
+
+
@@ -641,10 +650,6 @@
-
-
-
-
@@ -856,27 +861,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -891,13 +875,6 @@
-
-
-
-
-
-
-
@@ -912,27 +889,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -945,8 +905,52 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Pecee/Http/Url.php b/src/Pecee/Http/Url.php
index 099dd0a..3ee29b0 100644
--- a/src/Pecee/Http/Url.php
+++ b/src/Pecee/Http/Url.php
@@ -314,25 +314,36 @@ class Url implements \JsonSerializable
*/
public function hasParam(string $name): bool
{
- return \in_array($name, $this->getParams(), true);
+ return array_key_exists($name, $this->getParams());
}
/**
- * Removes parameter from query-string
+ * Removes multiple parameters from the query-string
+ *
+ * @param array ...$names
+ * @return static
+ */
+ public function removeParams(...$names): self
+ {
+ $params = array_diff_key($this->getParams(), array_flip($names));
+ $this->setParams($params);
+
+ return $this;
+ }
+
+ /**
+ * Removes parameter from the query-string
*
* @param string $name
+ * @return static
*/
- public function removeParam(string $name): void
+ public function removeParam(string $name): self
{
- if ($this->hasParam($name) === true) {
- $params = $this->getParams();
- $key = \array_search($name, $params, true);
+ $params = $this->getParams();
+ unset($params[$name]);
+ $this->setParams($params);
- if ($key === true) {
- unset($params[$key]);
- $this->setParams($params);
- }
- }
+ return $this;
}
/**
@@ -345,18 +356,7 @@ class Url implements \JsonSerializable
*/
public function getParam(string $name, ?string $defaultValue = null): ?string
{
- $output = null;
-
- if ($this->hasParam($name) === true) {
- $params = $this->getParams();
- $key = \array_search($name, $params, true);
-
- if ($key === true) {
- $output = $params[$key];
- }
- }
-
- return $output ?? $defaultValue;
+ return isset($this->getParams()[$name]) ?? $defaultValue;
}
/**
diff --git a/src/Pecee/SimpleRouter/SimpleRouter.php b/src/Pecee/SimpleRouter/SimpleRouter.php
index 3209812..b4faf62 100644
--- a/src/Pecee/SimpleRouter/SimpleRouter.php
+++ b/src/Pecee/SimpleRouter/SimpleRouter.php
@@ -447,7 +447,7 @@ class SimpleRouter
* @param array|null $getParams
* @return Url
*/
- public static function getUrl(?string $name = null, $parameters = null, $getParams = null): Url
+ public static function getUrl(?string $name = null, $parameters = null, ?array $getParams = null): Url
{
try {
return static::router()->getUrl($name, $parameters, $getParams);