@@ -82,7 +82,7 @@ public static function getServerName(string $serverIp): string
8282
8383 $ names = explode (', ' , env ('SERVER_NAMES ' , '' ));
8484 if (!empty ($ names )) {
85- foreach ($ names as $ def ) {
85+ foreach ($ names as $ def ) {
8686 $ def = explode ('= ' , $ def );
8787 if (sizeof ($ def ) === 2 && $ def [0 ] === $ host ) {
8888 return $ def [1 ];
@@ -98,9 +98,9 @@ public static function getServerName(string $serverIp): string
9898 *
9999 * @param string $serverIp
100100 * @param bool $useCache
101- * @return array
101+ * @return array|null
102102 */
103- public static function fetchSteamIdentifiers (string $ serverIp , bool $ useCache ): array
103+ public static function fetchSteamIdentifiers (string $ serverIp , bool $ useCache ): ? array
104104 {
105105 if (!$ serverIp ) {
106106 return [];
@@ -119,6 +119,10 @@ public static function fetchSteamIdentifiers(string $serverIp, bool $useCache):
119119 $ json = null ;
120120 try {
121121 $ json = GeneralHelper::get ($ serverIp . 'connections.json ' ) ?? null ;
122+
123+ if (!$ json ) {
124+ return null ;
125+ }
122126 } catch (Throwable $ t ) {
123127 return [];
124128 }
@@ -151,9 +155,9 @@ public static function fetchSteamIdentifiers(string $serverIp, bool $useCache):
151155 /**
152156 * Collects all the /api.json data from all servers
153157 *
154- * @return array
158+ * @return array|null
155159 */
156- public static function collectAllApiData (): array
160+ public static function collectAllApiData (): ? array
157161 {
158162 $ serverIps = explode (', ' , env ('OP_FW_SERVERS ' , '' ));
159163
@@ -173,16 +177,21 @@ public static function collectAllApiData(): array
173177 try {
174178 $ json = GeneralHelper::get ($ serverIp . 'api.json ' ) ?? [];
175179
176- $ response = OPFWHelper::parseResponse ($ json );
177-
178- if ($ response ->status && $ response ->data ) {
179- $ json = $ response ->data ;
180-
181- $ result [] = [
182- 'joined ' => isset ($ json ['joinedAmount ' ]) ? intval ($ json ['joinedAmount ' ]) : 0 ,
183- 'total ' => isset ($ json ['maxClients ' ]) ? intval ($ json ['maxClients ' ]) : 0 ,
184- 'queue ' => isset ($ json ['queueAmount ' ]) ? intval ($ json ['queueAmount ' ]) : 0 ,
185- ];
180+ if (!$ json ) {
181+ $ result = null ;
182+ break ;
183+ } else {
184+ $ response = OPFWHelper::parseResponse ($ json );
185+
186+ if ($ response ->status && $ response ->data ) {
187+ $ json = $ response ->data ;
188+
189+ $ result [] = [
190+ 'joined ' => isset ($ json ['joinedAmount ' ]) ? intval ($ json ['joinedAmount ' ]) : 0 ,
191+ 'total ' => isset ($ json ['maxClients ' ]) ? intval ($ json ['maxClients ' ]) : 0 ,
192+ 'queue ' => isset ($ json ['queueAmount ' ]) ? intval ($ json ['queueAmount ' ]) : 0 ,
193+ ];
194+ }
186195 }
187196 } catch (Throwable $ t ) {
188197 }
0 commit comments