diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index dade5770f8..3a56b85229 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -126,6 +126,18 @@ class ParameterBag implements ParameterBagInterface 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. */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index 5f5f265baa..29d2380909 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -43,6 +43,19 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase $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