Пример #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())
 {
     $collection = SquirtUtil::validateParamClass('collection', '\\MongoCollection', $params);
     $instance = new static($collection);
     $namespace = SquirtUtil::validateStringParamWithDefault('namespace', $params, 'squirt');
     if (strlen($namespace) > 0) {
         $instance->setNamespace($namespace);
     }
     return $instance;
 }
Пример #2
0
 /**
  * Create a new instance in a manner compatible
  * with the Squirt dependency injection
  * @param array $params
  */
 public static function factory(array $params = array())
 {
     $bucket = SquirtUtil::validateParamClass('bucket', 'Riak\\Bucket', $params);
     $instance = new static($bucket);
     $namespace = SquirtUtil::validateStringParamWithDefault('namespace', $params, 'squirt');
     if (strlen($namespace) > 0) {
         $instance->setNamespace($namespace);
     }
     return $instance;
 }
Пример #3
0
 /**
  * Create a new instance in a manner compatible
  * with the Squirt dependency injection
  * @param array $params
  */
 public static function factory(array $params = array())
 {
     $instance = new static();
     $redis = SquirtUtil::validateParamClass('redis', '\\Redis', $params);
     $instance->setRedis($redis);
     $namespace = SquirtUtil::validateStringParamWithDefault('namespace', $params, 'squirt');
     if (strlen($namespace) > 0) {
         $instance->setNamespace($namespace);
     }
     return $instance;
 }
Пример #4
0
 /**
  * Create a new instance in a manner compatible
  * with the Squirt dependency injection
  * @param array $params
  */
 public static function factory(array $params = array())
 {
     $instance = new static();
     /*
      * To make this work, we must have a memcache instance
      */
     $memcache = SquirtUtil::validateParamClass('memcache', '\\Memcache', $params);
     $instance->setMemcache($memcache);
     $namespace = SquirtUtil::validateStringParamWithDefault('namespace', $params, 'squirt');
     if (strlen($namespace) > 0) {
         $instance->setNamespace($namespace);
     }
     return $instance;
 }
Пример #5
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testValidateParamClassBadClass()
 {
     /*
      * The value does not match the class we expected
      * so this should throw an InvalidArgumentException
      */
     $result = SquirtUtil::validateParamClass('date', '\\DateTime', array('date' => new DateTimeZone('UTC')));
     $this->fail('Should not get here');
 }