@@ -20,6 +20,8 @@ class Config
2020
2121 public const MODE_PROXY = 'PROXY ' ;
2222
23+ private const KNOWN_MODES = ['PROXY ' , 'IDP ' , 'SP ' , 'MULTI_IDP ' ];
24+
2325 private const STORE = 'store ' ;
2426
2527 private const MODE = 'mode ' ;
@@ -40,22 +42,33 @@ class Config
4042
4143 private $ sourceIdpEntityIdAttribute ;
4244
45+ private $ tables ;
46+
47+ private $ keepPerUser ;
48+
49+ private $ requiredAuthSource ;
50+
51+ private $ idAttribute ;
52+
4353 private static $ instance ;
4454
4555 private function __construct ()
4656 {
4757 $ this ->config = Configuration::getConfig (self ::CONFIG_FILE_NAME );
4858 $ this ->store = $ this ->config ->getConfigItem (self ::STORE , null );
49- $ this ->tables = $ this ->config ->getArray ('tables ' , []);
50- $ this ->mode = $ this ->config ->getValueValidate (self ::MODE , ['PROXY ' , 'IDP ' , 'SP ' , 'MULTI_IDP ' ], 'PROXY ' );
59+ $ this ->tables = $ this ->config ->getArray ('tables ' , []);;
5160 $ this ->sourceIdpEntityIdAttribute = $ this ->config ->getString (self ::SOURCE_IDP_ENTITY_ID_ATTRIBUTE , '' );
61+ $ this ->mode = $ this ->config ->getValueValidate (self ::MODE , self ::KNOWN_MODES , self ::MODE_PROXY );
62+ $ this ->keepPerUser = $ this ->config ->getIntegerRange (self ::KEEP_PER_USER , 31 , 1827 , 31 );
63+ $ this ->requiredAuthSource = $ this ->config ->getString (self ::REQUIRE_AUTH_SOURCE , '' );
64+ $ this ->idAttribute = $ this ->config ->getString (self ::USER_ID_ATTRIBUTE , 'uid ' );
5265 }
5366
5467 private function __clone ()
5568 {
5669 }
5770
58- public static function getInstance ()
71+ public static function getInstance (): self
5972 {
6073 if (null === self ::$ instance ) {
6174 self ::$ instance = new self ();
@@ -81,17 +94,19 @@ public function getStore()
8194
8295 public function getIdAttribute ()
8396 {
84- return $ this ->config -> getString ( self :: USER_ID_ATTRIBUTE , ' uid ' ) ;
97+ return $ this ->idAttribute ;
8598 }
8699
87100 public function getSourceIdpEntityIdAttribute ()
88101 {
89102 return $ this ->sourceIdpEntityIdAttribute ;
90103 }
91104
92- public function getSideInfo ($ side )
105+ public function getSideInfo (string $ side )
93106 {
94- assert (in_array ($ side , [self ::SIDES ], true ));
107+ if (!in_array ($ side , self ::SIDES , true )) {
108+ throw new \Exception ('Unrecognized side parameter value passed \'' . $ side . '\'. ' );
109+ }
95110
96111 return array_merge ([
97112 'name ' => '' ,
@@ -101,11 +116,11 @@ public function getSideInfo($side)
101116
102117 public function getRequiredAuthSource ()
103118 {
104- return $ this ->config -> getString ( self :: REQUIRE_AUTH_SOURCE , '' ) ;
119+ return $ this ->requiredAuthSource ;
105120 }
106121
107122 public function getKeepPerUser ()
108123 {
109- return $ this ->config -> getIntegerRange ( self :: KEEP_PER_USER , 31 , 1827 , 31 ) ;
124+ return $ this ->keepPerUser ;
110125 }
111126}
0 commit comments