File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1414use chillerlan \Authenticator \Authenticators \AuthenticatorInterface ;
1515use chillerlan \Settings \SettingsContainerInterface ;
1616use SensitiveParameter ;
17+ use function is_iterable ;
1718
1819/**
1920 * Yet another Google authenticator implementation!
@@ -36,7 +37,7 @@ class Authenticator{
3637 * Authenticator constructor
3738 */
3839 public function __construct (
39- SettingsContainerInterface |AuthenticatorOptions $ options = new AuthenticatorOptions ,
40+ SettingsContainerInterface |AuthenticatorOptions | iterable $ options = new AuthenticatorOptions ,
4041 #[SensitiveParameter] string |null $ secret = null ,
4142 ){
4243 // phpcs:ignore
@@ -54,7 +55,12 @@ public function __construct(
5455 * Please note that this will reset the secret phrase stored with the authenticator instance
5556 * if a different mode than the current is given.
5657 */
57- public function setOptions (SettingsContainerInterface |AuthenticatorOptions $ options ):static {
58+ public function setOptions (SettingsContainerInterface |AuthenticatorOptions |iterable $ options ):static {
59+
60+ if (is_iterable ($ options )){
61+ $ options = new AuthenticatorOptions ($ options ); // @codeCoverageIgnore
62+ }
63+
5864 $ this ->options = $ options ;
5965
6066 // invoke a new authenticator interface if necessary
Original file line number Diff line number Diff line change 1818use RuntimeException ;
1919use SensitiveParameter ;
2020use function http_build_query ;
21+ use function is_iterable ;
2122use function random_bytes ;
2223use function rawurlencode ;
2324use function sprintf ;
@@ -37,11 +38,16 @@ abstract class AuthenticatorAbstract implements AuthenticatorInterface{
3738 /**
3839 * AuthenticatorInterface constructor
3940 */
40- public function __construct (SettingsContainerInterface |AuthenticatorOptions $ options = new AuthenticatorOptions ){
41+ public function __construct (SettingsContainerInterface |AuthenticatorOptions | iterable $ options = new AuthenticatorOptions ){
4142 $ this ->setOptions ($ options );
4243 }
4344
44- public function setOptions (SettingsContainerInterface $ options ):static {
45+ public function setOptions (SettingsContainerInterface |AuthenticatorOptions |iterable $ options ):static {
46+
47+ if (is_iterable ($ options )){
48+ $ options = new AuthenticatorOptions ($ options );
49+ }
50+
4551 $ this ->options = $ options ;
4652
4753 return $ this ;
You can’t perform that action at this time.
0 commit comments