Predis\Profile\Factory::define PHP Method

define() public static method

Registers a new server profile.
public static define ( string $alias, string $class )
$alias string Profile version or alias.
$class string FQN of a class implementing Predis\Profile\ProfileInterface.
    public static function define($alias, $class)
    {
        $reflection = new \ReflectionClass($class);
        if (!$reflection->isSubclassOf('Predis\\Profile\\ProfileInterface')) {
            throw new \InvalidArgumentException("The class '{$class}' is not a valid profile class.");
        }
        self::$profiles[$alias] = $class;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @group disconnected
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The class 'stdClass' is not a valid profile class.
  */
 public function testDefineInvalidProfile()
 {
     Factory::define('bogus', 'stdClass');
 }