symfony/symfony — pull request #4252 by taylorotwell (2012-05-10 16:12:35+00:00)
Title: [HttpFoundation] [ParameterBag] Added only() and except() methods to the HttpFoundation ParameterBag.

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

This pull adds two new methods to the HttpFoundation ParameterBag: `only` and `except`. These are useful for fetch a subset of the parameter bag as follows:

```
$bag = new ParameterBag(array('foo' => 'bar', 'baz' => 'bam'));

$array = $bag->only(array('foo'));

// $array is array('foo' => 'bar')

$array = $bag->except(array('foo'));

// $array is array('baz' => 'bam')
```

ParameterBag tests pass. No breaking changes.