예제 #1
0
 /**
  * Create a new instance in a manner compatible
  * with the Squirt dependency injection
  * @param array $params
  */
 public static function factory(array $params = array())
 {
     $dsn = SquirtUtil::validateStringParam('dsn', $params);
     $username = SquirtUtil::validateStringParamWithDefault('username', $params, '');
     $password = SquirtUtil::validateStringParamWithDefault('password', $params, '');
     $options = SquirtUtil::validateArrayParamWithDefault('options', $params, array());
     $instance = new static($dsn, $username, $password, $options);
     return $instance;
 }
예제 #2
0
 public function testValidateArrayParamWithDefault()
 {
     $result = SquirtUtil::validateArrayParamWithDefault('set', array('set' => array(1, 2, 3)), array());
     $this->assertEquals(array(1, 2, 3), $result);
     $result = SquirtUtil::validateArrayParamWithDefault('set', array(), array(5));
     $this->assertEquals(array(5), $result);
 }