[DependencyInjection] Add ParameterBag::remove
This commit is contained in:
parent
f14961b747
commit
3d9990a0ec
@ -126,6 +126,18 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
return array_key_exists(strtolower($name), $this->parameters);
|
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.
|
* Replaces parameter placeholders (%name%) by their values for all parameters.
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +43,19 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array(), $bag->all(), '->clear() removes all parameters');
|
$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::get
|
||||||
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::set
|
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::set
|
||||||
|
Reference in New Issue
Block a user