6060 */
6161class BigBlueButton
6262{
63- protected string $ securitySecret ;
64- protected string $ bbbServerBaseUrl ;
63+ protected string $ bbbSecret ;
64+ protected string $ bbbBaseUrl ;
6565 protected UrlBuilder $ urlBuilder ;
6666 protected string $ jSessionId ;
6767
@@ -78,12 +78,27 @@ class BigBlueButton
7878 */
7979 public function __construct (?string $ baseUrl = null , ?string $ secret = null , ?array $ opts = [])
8080 {
81+ // Provide an early error message if configuration is wrong
82+ if (is_null ($ secret ) && false === getenv ('BBB_SERVER_BASE_URL ' )) {
83+ throw new \RuntimeException ('No BBB-Server-Url found! Please provide it either in constructor ' .
84+ "(1st argument) or by environment variable 'BBB_SERVER_BASE_URL'! " );
85+ }
86+
87+ if (is_null ($ secret ) && false === getenv ('BBB_SECRET ' ) && false === getenv ('BBB_SECURITY_SALT ' )) {
88+ throw new \RuntimeException ('No BBB-Secret (or BBB-Salt) found! Please provide it either in constructor ' .
89+ "(2nd argument) or by environment variable 'BBB_SECRET' (or 'BBB_SECURITY_SALT')! " );
90+ }
91+
8192 // Keeping backward compatibility with older deployed versions
8293 // BBB_SECRET is the new variable name and have higher priority against the old named BBB_SECURITY_SALT
83- $ this ->securitySecret = $ secret ?: getenv ('BBB_SECRET ' ) ?: getenv ('BBB_SECURITY_SALT ' ) ?: '' ;
84- $ this ->bbbServerBaseUrl = $ baseUrl ?: getenv ('BBB_SERVER_BASE_URL ' ) ?: '' ;
94+ // Reminder: getenv() will return FALSE if not set. But bool is not accepted by $this->bbbSecret
95+ // nor $this->bbbBaseUrl (only strings), thus FALSE will be converted automatically to an empty
96+ // string (''). Having a bool should be not possible due to the checks above and the automated
97+ // conversion, but PHPStan is still unhappy, so it's covered explicit by adding `?: ''`.
98+ $ this ->bbbBaseUrl = $ baseUrl ?: getenv ('BBB_SERVER_BASE_URL ' ) ?: '' ;
99+ $ this ->bbbSecret = $ secret ?: getenv ('BBB_SECRET ' ) ?: getenv ('BBB_SECURITY_SALT ' ) ?: '' ;
85100 $ this ->hashingAlgorithm = HashingAlgorithm::SHA_256 ;
86- $ this ->urlBuilder = new UrlBuilder ($ this ->securitySecret , $ this ->bbbServerBaseUrl , $ this ->hashingAlgorithm );
101+ $ this ->urlBuilder = new UrlBuilder ($ this ->bbbSecret , $ this ->bbbBaseUrl , $ this ->hashingAlgorithm );
87102 $ this ->curlOpts = $ opts ['curl ' ] ?? [];
88103 }
89104
0 commit comments