Skip to content

Commit 4bed08a

Browse files
committed
Add a method used to compare this URI with another for equality
1 parent 8170937 commit 4bed08a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/WaterPipe/HTTP/Request/RequestUri.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
class RequestUri implements \ArrayAccess
3838
{
3939
/**
40-
* @type string
40+
* @var string
4141
*/
42-
private const URI_PARAM_PATTERN = "#:(\w+)#";
42+
private const URI_PARAM_PATTERN = "/:(\w+)/";
4343

4444
/**
4545
* @var string
@@ -61,6 +61,18 @@ class RequestUri implements \ArrayAccess
6161
*/
6262
private $_built = false;
6363

64+
/**
65+
* Checks if the this URI is equal tu the given one.
66+
*
67+
* @param string $uri The URI to compare with this instance.
68+
*
69+
* @return bool
70+
*/
71+
public function is(string $uri): bool
72+
{
73+
return strtolower(trim($this->_uri, "/")) === strtolower(trim($uri, "/"));
74+
}
75+
6476
/**
6577
* @param string $pattern
6678
*
@@ -266,4 +278,4 @@ public function offsetUnset($offset)
266278
unset($this->_params[$offset]);
267279
}
268280
}
269-
}
281+
}

0 commit comments

Comments
 (0)