Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
add stubbles\peer\Uri::addParams()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey179 committed Oct 13, 2014
1 parent c894c45 commit f1d6f8d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
5.1.2 (2014-10-13)
------------------

* added `stubbles\peer\Uri::addParams()`


5.1.1 (2014-10-03)
------------------

Expand Down
18 changes: 17 additions & 1 deletion src/main/php/peer/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
14 changes: 14 additions & 0 deletions src/test/php/peer/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit f1d6f8d

Please sign in to comment.