Horde_Crypt::factory PHP Method

factory() public static method

Attempts to return a concrete Horde_Crypt instance based on $driver.
public static factory ( string $driver, array $params = [] ) : Horde_Crypt
$driver string Either a driver name, or the full class name to use (class must extend Horde_Crypt).
$params array A hash containing any additional configuration or parameters a subclass might need.
return Horde_Crypt The newly created concrete instance.
    public static function factory($driver, $params = array())
    {
        /* Return a base Horde_Crypt object if no driver is specified. */
        if (empty($driver) || strcasecmp($driver, 'none') == 0) {
            return new Horde_Crypt();
        }
        /* Base drivers (in Crypt/ directory). */
        $class = __CLASS__ . '_' . Horde_String::ucfirst(basename($driver));
        if (class_exists($class)) {
            return new $class($params);
        }
        /* Explicit class name, */
        $class = $driver;
        if (class_exists($class)) {
            return new $class($params);
        }
        throw new Horde_Crypt_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
    }

Usage Example

Ejemplo n.º 1
0
 protected function setUp()
 {
     $backends = $this->_setUp();
     @date_default_timezone_set('GMT');
     $this->_language = getenv('LANGUAGE');
     $this->_pgp = Horde_Crypt::factory('Pgp', array('backends' => $backends));
 }
All Usage Examples Of Horde_Crypt::factory