/** * * @param string $name * @param string $converter * @param ParameterBag $properties */ public function __construct($name, $converter = null, ParameterBag $properties = null) { $this->name = $name; $this->converter = $converter ?: self::$defaultConverter; $params = $properties ? $properties->toArray() : array(); $this->properties = new ParameterBag(array_merge(self::$defaultParameters, $params)); }
public function testMainFunctionality() { $bag = new ParameterBag(array('foo' => 'bar', 'test' => 123)); $this->assertEquals('bar', $bag->get('foo')); $this->assertEquals(123, $bag->get('test')); $this->assertEquals('bar', $bag['foo']); $this->assertEquals(123, $bag['test']); $this->assertEquals(false, isset($bag['xxx'])); $bag['xxx'] = 'yyy'; $this->assertEquals('yyy', $bag->get('xxx')); $this->assertEquals(true, isset($bag['xxx'])); unset($bag['xxx']); $this->assertEquals(false, $bag->has('xxx')); $this->assertEquals('bar', $bag->get('foo')); $this->assertEquals(123, $bag->get('test')); }