File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,6 +148,32 @@ private static function setAppropriateEnv()
148148 {
149149 $ currentEnv = (self ::$ testMode ) ? Environment::TEST : Environment::PROD ;
150150 self ::$ env = strtolower ($ currentEnv );
151- }
151+ }
152+
153+ public static function setEnv ($ env )
154+ {
155+ if (Check::isEnvAllowed ($ env ))
156+ {
157+ self ::$ env = strtolower ($ env );
158+ self ::setApproriateLiveAndTestMode ();
159+ }
160+ else
161+ {
162+ throw new \Exception ('The ' . $ env . ' is not allowed. Please chose between test or prod ! ' );
163+ }
164+ }
165+
166+ private static function setApproriateLiveAndTestMode ()
167+ {
168+ switch (self ::getEnv ())
169+ {
170+ case 'test ' :
171+ self ::setTestMode (true );
172+ self ::setLiveMode (false );
173+ case 'prod ' :
174+ self ::setTestMode (false );
175+ self ::setLiveMode (true );
176+ }
177+ }
152178
153179}
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ abstract class Check
2626
2727 public static function isCurrencyAllowed ($ currency )
2828 {
29- return array_search ($ currency , self ::authorizedCurrency);
29+ return array_search (strtoupper ( $ currency) , self ::authorizedCurrency);
3030 }
3131
3232 public static function isEnvAllowed ($ env )
3333 {
34- return array_search ($ $ env , self ::autorizedEnv);
34+ return array_search (strtoupper ( $ env) , self ::autorizedEnv);
3535 }
3636}
You can’t perform that action at this time.
0 commit comments