diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b3cbd..c812063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +5.1.2 (2014-10-13) +------------------ + + * added `stubbles\peer\Uri::addParams()` + + 5.1.1 (2014-10-03) ------------------ diff --git a/src/main/php/peer/Uri.php b/src/main/php/peer/Uri.php index cd69de2..b5f5760 100644 --- a/src/main/php/peer/Uri.php +++ b/src/main/php/peer/Uri.php @@ -250,12 +250,28 @@ public function queryString() return $this->parsedUri->queryString()->build(); } + /** + * adds given map of params + * + * @param array $params map of parameters to add + * @return \stubbles\peer\Uri + * @since 5.1.2 + */ + public function addParams(array $params) + { + foreach ($params as $name => $value) { + $this->addParam($name, $value); + } + + return $this; + } + /** * add a parameter to the uri * * @param string $name name of parameter * @param mixed $value value of parameter - * @return Uri + * @return \stubbles\peer\Uri */ public function addParam($name, $value) { diff --git a/src/test/php/peer/UriTest.php b/src/test/php/peer/UriTest.php index 91f8ff5..2fd928f 100644 --- a/src/test/php/peer/UriTest.php +++ b/src/test/php/peer/UriTest.php @@ -854,6 +854,20 @@ public function removeExistingParamChangesQueryString() ); } + /** + * @test + * @since 5.1.2 + */ + public function addParamsChangesQueryString() + { + $this->assertEquals( + 'http://example.org/?wsdl&foo=bar&baz=303', + Uri::fromString('http://example.org/?wsdl') + ->addParams(['foo' => 'bar', 'baz' => '303']) + ->asStringWithoutPort() + ); + } + /** * @test */