File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public function getLatency(): int
8989 {
9090 return $ this ->latency ;
9191 }
92-
92+
9393 public static function fromRawData (array $ rawData ): self
9494 {
9595 return new self (
@@ -98,9 +98,25 @@ public static function fromRawData(array $rawData): self
9898 isset ($ rawData ['players ' ]['online ' ]) ? (int ) $ rawData ['players ' ]['online ' ] : 0 ,
9999 isset ($ rawData ['players ' ]['max ' ]) ? (int ) $ rawData ['players ' ]['max ' ] : 0 ,
100100 isset ($ rawData ['players ' ]['sample ' ]) ? (array ) $ rawData ['players ' ]['sample ' ] : [],
101- isset ($ rawData ['description ' ][ ' text ' ]) ? ( string ) $ rawData ['description ' ][ ' text ' ] : '' ,
101+ isset ($ rawData ['description ' ]) ? ( is_array ( $ rawData [ ' description ' ]) ? self :: readMessageOfTheDay ( $ rawData ['description ' ]) : ( string ) $ rawData [ ' description ' ]) : '' ,
102102 (int ) $ rawData ['latency ' ],
103103 isset ($ rawData ['favicon ' ]) ? (string ) $ rawData ['favicon ' ] : null
104104 );
105105 }
106+
107+ private static function readMessageOfTheDay (array $ description ): string
108+ {
109+ $ messageOfTheDay = '' ;
110+
111+ if (isset ($ description ['extra ' ])) {
112+ foreach ($ description ['extra ' ] as $ extra ) {
113+ if (isset ($ extra ['extra ' ])) {
114+ $ messageOfTheDay .= self ::readMessageOfTheDay ($ extra );
115+ }
116+ $ messageOfTheDay .= ($ extra ['text ' ] ?? '' );
117+ }
118+ }
119+
120+ return $ messageOfTheDay . ($ description ['text ' ] ?? '' );
121+ }
106122}
You can’t perform that action at this time.
0 commit comments