Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[DependencyInjection] Add ParameterBag::remove
  • Loading branch information
Seldaek committed May 7, 2012
1 parent f14961b commit 3d9990a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -126,6 +126,18 @@ public function has($name)
return array_key_exists(strtolower($name), $this->parameters);
}

/**
* Removes a parameter.
*
* @param string $key The key
*
* @api
*/
public function remove($key)
{
unset($this->parameters[$key]);
}

/**
* Replaces parameter placeholders (%name%) by their values for all parameters.
*/
Expand Down
Expand Up @@ -43,6 +43,19 @@ public function testClear()
$this->assertEquals(array(), $bag->all(), '->clear() removes all parameters');
}

/**
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::remove
*/
public function testRemove()
{
$bag = new ParameterBag(array(
'foo' => 'foo',
'bar' => 'bar',
));
$bag->remove('foo');
$this->assertEquals(array('bar' => 'bar'), $bag->all(), '->remove() removes a parameter');
}

/**
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::set
Expand Down

0 comments on commit 3d9990a

Please sign in to comment.