/** * @param array $algorithms * * @return \Jose\Algorithm\JWAManagerInterface */ public static function createAlgorithmManager(array $algorithms) { $jwa_manager = new JWAManager(); foreach ($algorithms as $algorithm) { if ($algorithm instanceof JWAInterface) { $jwa_manager->addAlgorithm($algorithm); } else { $class = self::getAlgorithmClass($algorithm); $jwa_manager->addAlgorithm(new $class()); } } return $jwa_manager; }
/** * @param string[]|\Jose\Algorithm\JWAInterface[] $algorithms * * @return \Jose\Algorithm\JWAManagerInterface */ public static function createAlgorithmManager(array $algorithms) { $jwa_manager = new JWAManager(); foreach ($algorithms as $algorithm) { if ($algorithm instanceof JWAInterface) { $jwa_manager->addAlgorithm($algorithm); } else { Assertion::string($algorithm, 'Bad argument: must be a list with either algorithm names (string) or instances of JWAInterface.'); $class = self::getAlgorithmClass($algorithm); $jwa_manager->addAlgorithm(new $class()); } } return $jwa_manager; }