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
89
89
{
90
90
return $ this ->latency ;
91
91
}
92
-
92
+
93
93
public static function fromRawData (array $ rawData ): self
94
94
{
95
95
return new self (
@@ -98,9 +98,25 @@ public static function fromRawData(array $rawData): self
98
98
isset ($ rawData ['players ' ]['online ' ]) ? (int ) $ rawData ['players ' ]['online ' ] : 0 ,
99
99
isset ($ rawData ['players ' ]['max ' ]) ? (int ) $ rawData ['players ' ]['max ' ] : 0 ,
100
100
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 ' ]) : '' ,
102
102
(int ) $ rawData ['latency ' ],
103
103
isset ($ rawData ['favicon ' ]) ? (string ) $ rawData ['favicon ' ] : null
104
104
);
105
105
}
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
+ }
106
122
}
You can’t perform that action at this time.
0 commit comments