Esempio n. 1
0
 public function testGet()
 {
     $bag = new ParameterBag(array('a' => 'ValueA', 'b' => null));
     $this->assertEquals('ValueA', $bag->get('a'));
     $this->assertNull($bag->get('b', 'NotNull'));
     $this->assertEquals('defaultValue', $bag->get('c', 'defaultValue'));
 }
Esempio n. 2
0
 /**
  * Retrieve a configuration parameter, or throw an exception if the parameter doesn't exist
  * and there is no default value
  *
  * @see ParameterBag
  * @throws ConfigurationException If the request property doesn't exist
  */
 public function get($name, $default = null)
 {
     if (!$this->has($name) && $default === null) {
         throw new ConfigurationException(sprintf("Missing configuration parameter '%s'", $name));
     }
     return parent::get($name, $default);
 }