diff --git a/Uri/Argument.php b/Uri/Argument.php index c88c7796c..55426691a 100755 --- a/Uri/Argument.php +++ b/Uri/Argument.php @@ -322,6 +322,20 @@ final class Argument implements UriInterface return $this->pathElements[$pos + ($useOffset ? $this->pathOffset : 0)] ?? ''; } + /** + * {@inheritdoc} + */ + public function getPathKey(string $key) : string + { + foreach ($this->pathElements as $index => $element) { + if ($element === $key) { + return $this->pathElements[$index + 1] ?? ''; + } + } + + return ''; + } + /** * {@inheritdoc} */ diff --git a/Uri/HttpUri.php b/Uri/HttpUri.php index 779c2e403..6d4a7cd3a 100755 --- a/Uri/HttpUri.php +++ b/Uri/HttpUri.php @@ -391,6 +391,20 @@ final class HttpUri implements UriInterface return $this->pathElements[$pos + ($useOffset ? $this->pathOffset : 0)] ?? ''; } + /** + * {@inheritdoc} + */ + public function getPathKey(string $key) : string + { + foreach ($this->pathElements as $index => $element) { + if ($element === $key) { + return $this->pathElements[$index + 1] ?? ''; + } + } + + return ''; + } + /** * {@inheritdoc} */ diff --git a/Uri/UriInterface.php b/Uri/UriInterface.php index 89c3528c3..da6a92a59 100755 --- a/Uri/UriInterface.php +++ b/Uri/UriInterface.php @@ -128,6 +128,17 @@ interface UriInterface */ public function getPathElement(int $pos = 0, bool $useOffset = true) : string; + /** + * Get the value after a key + * + * @param string $key Key to search for in path + * + * @return string + * + * @since 1.0.0 + */ + public function getPathKey(string $key) : string; + /** * Get path elements. *