/** * Set the symmetric cipher plugin manager * * @param string|SymmetricPluginManager $plugins * @throws Exception\InvalidArgumentException */ public static function setSymmetricPluginManager($plugins) { if (is_string($plugins)) { if (!class_exists($plugins)) { throw new Exception\InvalidArgumentException(sprintf('Unable to locate symmetric cipher plugins using class "%s"; class does not exist', $plugins)); } $plugins = new $plugins(); } if (!$plugins instanceof SymmetricPluginManager) { throw new Exception\InvalidArgumentException(sprintf('Expected an instance or extension of %s\\SymmetricPluginManager; received "%s"', __NAMESPACE__, is_object($plugins) ? get_class($plugins) : gettype($plugins))); } self::$symmetricPlugins = $plugins; }
/** * Set the symmetric cipher broker * * @param string|SymmetricBroker $broker * @throws Exception\InvalidArgumentException */ public static function setSymmetricBroker($broker) { if (is_string($broker)) { if (!class_exists($broker)) { throw new Exception\InvalidArgumentException( sprintf( 'Unable to locate symmetric cipher broker of class "%s"', $broker )); } $broker = new $broker(); } if (!$broker instanceof SymmetricBroker) { throw new Exception\InvalidArgumentException( sprintf( 'Symmetric cipher broker must extend SymmetricBroker; received "%s"', (is_object($broker) ? get_class($broker) : gettype($broker)) )); } self::$symmetricBroker = $broker; }