@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | $result->add('num_grfs', $num_grfs); |
139 | 139 | //$buffer->skip ($num_grfs * 20); #skip grfs id and md5 hash |
140 | 140 | |
141 | - for ($i=0; $i<$num_grfs; $i++) { |
|
142 | - $result->add('grfs_'.$i.'_ID', strtoupper(bin2hex($buffer->read(4)))); |
|
143 | - $result->add('grfs_'.$i.'_MD5', strtoupper(bin2hex($buffer->read(16)))); |
|
141 | + for ($i = 0; $i < $num_grfs; $i++) { |
|
142 | + $result->add('grfs_' . $i . '_ID', strtoupper(bin2hex($buffer->read(4)))); |
|
143 | + $result->add('grfs_' . $i . '_MD5', strtoupper(bin2hex($buffer->read(16)))); |
|
144 | 144 | } |
145 | 145 | // No break, cascades all the down even if case is meet |
146 | 146 | case 3: |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | |
159 | 159 | $language = $buffer->readInt8(); |
160 | 160 | $result->add('language', $language); |
161 | - $result->add('language_icon', '//media.openttd.org/images/server/'.$language.'_lang.gif'); |
|
161 | + $result->add('language_icon', '//media.openttd.org/images/server/' . $language . '_lang.gif'); |
|
162 | 162 | |
163 | 163 | $result->add('password', $buffer->readInt8()); |
164 | 164 | $result->add('max_clients', $buffer->readInt8()); |
165 | 165 | $result->add('clients', $buffer->readInt8()); |
166 | 166 | $result->add('spectators', $buffer->readInt8()); |
167 | 167 | if ($protocol_version < 3) { |
168 | - $days = ( 365 * 1920 + 1920 / 4 - 1920 / 100 + 1920 / 400 ); |
|
168 | + $days = (365 * 1920 + 1920 / 4 - 1920 / 100 + 1920 / 400); |
|
169 | 169 | $result->add('game_date', $buffer->readInt16() + $days); |
170 | 170 | $result->add('start_date', $buffer->readInt16() + $days); |
171 | 171 | } |
@@ -135,7 +135,7 @@ |
||
135 | 135 | throw new Exception("JSON response from Gtar protocol is invalid."); |
136 | 136 | } |
137 | 137 | |
138 | - $address = $this->realIp.':'.$this->realPortQuery; |
|
138 | + $address = $this->realIp . ':' . $this->realPortQuery; |
|
139 | 139 | $server = $json->$address; |
140 | 140 | |
141 | 141 | if (empty($server)) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $server_addr = explode(':', $ip_address); |
171 | 171 | |
172 | 172 | // Port is the last item in the array, remove it and save |
173 | - $this->port_client = (int)array_pop($server_addr); |
|
173 | + $this->port_client = (int) array_pop($server_addr); |
|
174 | 174 | |
175 | 175 | // The rest is the address, recombine |
176 | 176 | $this->ip = implode(':', $server_addr); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | // Now let's validate the IPv6 value sent, remove the square brackets ([]) first |
188 | - if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6,])) { |
|
188 | + if (!filter_var(trim($this->ip, '[]'), FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV6, ])) { |
|
189 | 189 | throw new Exception("The IPv6 address '{$this->ip}' is invalid."); |
190 | 190 | } |
191 | 191 | } else { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | list($this->ip, $this->port_client) = explode(':', $ip_address); |
195 | 195 | |
196 | 196 | // Type case the port |
197 | - $this->port_client = (int)$this->port_client; |
|
197 | + $this->port_client = (int) $this->port_client; |
|
198 | 198 | } else { |
199 | 199 | // No port, fail |
200 | 200 | throw new Exception( |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | // Validate the IPv4 value, if FALSE is not a valid IP, maybe a hostname. |
207 | - if (! filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4,])) { |
|
207 | + if (!filter_var($this->ip, FILTER_VALIDATE_IP, ['flags' => FILTER_FLAG_IPV4, ])) { |
|
208 | 208 | // Try to resolve the hostname to IPv4 |
209 | 209 | $resolved = gethostbyname($this->ip); |
210 | 210 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | // Specific query port defined |
229 | 229 | if (array_key_exists(self::SERVER_OPTIONS_QUERY_PORT, $this->options)) { |
230 | - $this->port_query = (int)$this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
230 | + $this->port_query = (int) $this->options[self::SERVER_OPTIONS_QUERY_PORT]; |
|
231 | 231 | } else { |
232 | 232 | // Do math based on the protocol class |
233 | 233 | $this->port_query = $this->protocol->findQueryPort($this->port_client); |
@@ -191,7 +191,7 @@ |
||
191 | 191 | $result->addSub('mods', 'steam_id', $responseBuffer->readInt32($infoByte & 0x0F)); |
192 | 192 | |
193 | 193 | // Read the name of the mod |
194 | - $result->addSub('mods', 'name', $responseBuffer->readPascalString(0, true) ?: 'Unknown'); |
|
194 | + $result->addSub('mods', 'name', $responseBuffer->readPascalString(0, true) ? : 'Unknown'); |
|
195 | 195 | |
196 | 196 | --$modCount; |
197 | 197 | } |
@@ -147,16 +147,16 @@ |
||
147 | 147 | |
148 | 148 | $result->add('edition', $info[0]); |
149 | 149 | $result->add('motd_line_1', $info[1]); |
150 | - $result->add('protocol_version', (int)$info[2]); |
|
150 | + $result->add('protocol_version', (int) $info[2]); |
|
151 | 151 | $result->add('version', $info[3]); |
152 | - $result->add('num_players', (int)$info[4]); |
|
153 | - $result->add('max_players', (int)$info[5]); |
|
152 | + $result->add('num_players', (int) $info[4]); |
|
153 | + $result->add('max_players', (int) $info[5]); |
|
154 | 154 | $result->add('server_uid', $info[6]); |
155 | 155 | $result->add('motd_line_2', $info[7]); |
156 | 156 | $result->add('gamemode', $info[8]); |
157 | - $result->add('gamemode_numeric', (int)$info[9]); |
|
158 | - $result->add('port_ipv4', (isset($info[10])) ? (int)$info[10] : null); |
|
159 | - $result->add('port_ipv6', (isset($info[11])) ? (int)$info[11] : null); |
|
157 | + $result->add('gamemode_numeric', (int) $info[9]); |
|
158 | + $result->add('port_ipv4', (isset($info[10])) ? (int) $info[10] : null); |
|
159 | + $result->add('port_ipv6', (isset($info[11])) ? (int) $info[11] : null); |
|
160 | 160 | $result->add('dedicated', 1); |
161 | 161 | |
162 | 162 | unset($header, $serverGUID, $magicCheck, $info); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function __construct(array $options = []) |
61 | 61 | { |
62 | 62 | // Check for passed keys |
63 | - if (! array_key_exists(self::OPTION_TIMEKEYS, $options)) { |
|
63 | + if (!array_key_exists(self::OPTION_TIMEKEYS, $options)) { |
|
64 | 64 | // Use default |
65 | 65 | $options[self::OPTION_TIMEKEYS] = $this->timeKeysDefault; |
66 | 66 | } else { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | (is_numeric($value)) |
91 | 91 | ) { |
92 | 92 | /* Ensure the value is float */ |
93 | - if (! is_float($value)) { |
|
93 | + if (!is_float($value)) { |
|
94 | 94 | $value = floatval($value); |
95 | 95 | } |
96 | 96 | |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | /* Format the provided time */ |
102 | 102 | sprintf( |
103 | 103 | '%02d:%02d:%02d', |
104 | - (int)floor($value / 3600), // Hours |
|
105 | - (int)fmod(($value / 60), 60), // Minutes |
|
106 | - (int)fmod($value, 60) // Seconds |
|
104 | + (int) floor($value / 3600), // Hours |
|
105 | + (int) fmod(($value / 60), 60), // Minutes |
|
106 | + (int) fmod($value, 60) // Seconds |
|
107 | 107 | ) |
108 | 108 | ); |
109 | 109 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function apply(array $result, Server $server) |
53 | 53 | { |
54 | 54 | /* Prevent working on empty results */ |
55 | - if (! empty($result)) { |
|
55 | + if (!empty($result)) { |
|
56 | 56 | /* Handle unit test data generation */ |
57 | 57 | if ($this->writeTestData) { |
58 | 58 | /* Initialize potential data for unit testing **/ |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (is_string($value)) { |
71 | 71 | /* Strip the colors and update the value by reference */ |
72 | 72 | $value = $executor($value); |
73 | - } elseif (! is_array($value)) { |
|
73 | + } elseif (!is_array($value)) { |
|
74 | 74 | $value = (string) $value; // TODO: Remove this in the next major version. |
75 | 75 | } |
76 | 76 | }); |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | public function apply(array $result, Server $server) |
58 | 58 | { |
59 | 59 | /* Determine if there is data to be processed */ |
60 | - if (! empty($result)) { |
|
60 | + if (!empty($result)) { |
|
61 | 61 | /* Handle unit test data generation */ |
62 | 62 | if ($this->writeTestData) { |
63 | 63 | /* Initialize potential data for unit testing **/ |
64 | - $unitTestData = [ ]; |
|
64 | + $unitTestData = []; |
|
65 | 65 | |
66 | 66 | /* Add the initial result to the unit test data */ |
67 | 67 | $unitTestData['raw'][$server->id()] = $result; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | /* Process each mapping individually */ |
127 | 127 | foreach ($this->normalize[$section] as $target => $source) { |
128 | 128 | /* Treat explicit source like implicit sources */ |
129 | - if (! is_array($source)) { |
|
129 | + if (!is_array($source)) { |
|
130 | 130 | $source = [$source]; |
131 | 131 | } |
132 | 132 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | /* Determine if the current source does exist */ |
136 | 136 | if (array_key_exists($s, $data)) { |
137 | 137 | /* Add the normalized mapping */ |
138 | - $normalized['gq_'.$target] = $data[$s]; |
|
138 | + $normalized['gq_' . $target] = $data[$s]; |
|
139 | 139 | break; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | /* Write null in case no source was found */ |
144 | 144 | // TODO: Remove this in the next major version. |
145 | - $normalized['gq_'.$target] = isset($normalized['gq_'.$target]) ? $normalized['gq_'.$target] : null; |
|
145 | + $normalized['gq_' . $target] = isset($normalized['gq_' . $target]) ? $normalized['gq_' . $target] : null; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -193,12 +193,12 @@ |
||
193 | 193 | $serverFlags = $buffer->readInt8(); |
194 | 194 | |
195 | 195 | // Read server flags |
196 | - $result->add('password', (int)$this->readFlag($serverFlags, 0)); |
|
197 | - $result->add('registered_only', (int)$this->readFlag($serverFlags, 1)); |
|
198 | - $result->add('fog_of_war', (int)$this->readFlag($serverFlags, 2)); |
|
199 | - $result->add('friendly_fire', (int)$this->readFlag($serverFlags, 3)); |
|
200 | - $result->add('bots_enabled', (int)$this->readFlag($serverFlags, 5)); |
|
201 | - $result->add('lua_scripts', (int)$this->readFlag($serverFlags, 6)); |
|
196 | + $result->add('password', (int) $this->readFlag($serverFlags, 0)); |
|
197 | + $result->add('registered_only', (int) $this->readFlag($serverFlags, 1)); |
|
198 | + $result->add('fog_of_war', (int) $this->readFlag($serverFlags, 2)); |
|
199 | + $result->add('friendly_fire', (int) $this->readFlag($serverFlags, 3)); |
|
200 | + $result->add('bots_enabled', (int) $this->readFlag($serverFlags, 5)); |
|
201 | + $result->add('lua_scripts', (int) $this->readFlag($serverFlags, 6)); |
|
202 | 202 | |
203 | 203 | // Read the rest of the buffer data |
204 | 204 | $result->add('servername', Str::isoToUtf8($buffer->readPascalString(0))); |