Completed
Push — master ( 4250c2...96386f )
by Daniel
30s queued 13s
created
lib/OperatingSystems/FreeBSD.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 			$swapinfo = '';
46 46
 		}
47 47
 
48
-		$matches = [];
48
+		$matches = [ ];
49 49
 		$pattern = '/(?>\/dev\/\S+)\s+(?>\d+)\s+(?<Used>\d+)\s+(?<Avail>\d+)\s+(?<Capacity>\d+)/';
50 50
 
51 51
 		$result = preg_match_all($pattern, $swapinfo, $matches);
52 52
 		if ($result !== 0) {
53
-			$data->setSwapTotal((int)((int)array_sum($matches['Avail']) / 1024));
54
-			$data->setSwapFree(($data->getSwapTotal() - (int)((int)array_sum($matches['Used']) / 1024)));
53
+			$data->setSwapTotal((int) ((int) array_sum($matches[ 'Avail' ]) / 1024));
54
+			$data->setSwapFree(($data->getSwapTotal() - (int) ((int) array_sum($matches[ 'Used' ]) / 1024)));
55 55
 		}
56 56
 
57 57
 		unset($matches, $result);
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 
65 65
 		$lines = array_map('intval', explode("\n", $meminfo));
66 66
 		if (count($lines) > 4) {
67
-			$data->setMemTotal((int)($lines[0] / 1024 / 1024));
68
-			$data->setMemAvailable((int)(($lines[1] * ($lines[2] + $lines[3] + $lines[4])) / 1024 / 1024));
67
+			$data->setMemTotal((int) ($lines[ 0 ] / 1024 / 1024));
68
+			$data->setMemAvailable((int) (($lines[ 1 ] * ($lines[ 2 ] + $lines[ 3 ] + $lines[ 4 ])) / 1024 / 1024));
69 69
 		}
70 70
 
71 71
 		unset($lines);
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			$model = $this->executeCommand('/sbin/sysctl -n hw.model');
81 81
 			$cores = $this->executeCommand('/sbin/sysctl -n kern.smp.cpus');
82 82
 
83
-			if ((int)$cores === 1) {
84
-				$data = $model . ' (1 core)';
83
+			if ((int) $cores === 1) {
84
+				$data = $model.' (1 core)';
85 85
 			} else {
86
-				$data = $model . ' (' . $cores . ' cores)';
86
+				$data = $model.' ('.$cores.' cores)';
87 87
 			}
88 88
 		} catch (RuntimeException $e) {
89 89
 			return $data;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			$shell_boot = $this->executeCommand('/sbin/sysctl -n kern.boottime');
107 107
 			preg_match("/[\d]+/", $shell_boot, $boottime);
108 108
 			$time = $this->executeCommand('date +%s');
109
-			$uptime = (int)$time - (int)$boottime[0];
109
+			$uptime = (int) $time - (int) $boottime[ 0 ];
110 110
 		} catch (RuntimeException $e) {
111 111
 			return $uptime;
112 112
 		}
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 	}
115 115
 
116 116
 	public function getNetworkInfo(): array {
117
-		$result = [];
118
-		$result['hostname'] = \gethostname();
117
+		$result = [ ];
118
+		$result[ 'hostname' ] = \gethostname();
119 119
 
120 120
 		try {
121 121
 			$dns = $this->executeCommand('cat /etc/resolv.conf 2>/dev/null');
122 122
 			preg_match_all("/(?<=^nameserver ).\S*/m", $dns, $matches);
123
-			$alldns = implode(' ', $matches[0]);
124
-			$result['dns'] = $alldns;
123
+			$alldns = implode(' ', $matches[ 0 ]);
124
+			$result[ 'dns' ] = $alldns;
125 125
 			$netstat = $this->executeCommand('netstat -rn');
126 126
 			preg_match_all("/(?<=^default)\s*[0-9a-fA-f\.:]+/m", $netstat, $gw);
127
-			if (count($gw[0]) > 0) {
128
-				$result['gateway'] = implode(", ", array_map("trim", $gw[0]));
127
+			if (count($gw[ 0 ]) > 0) {
128
+				$result[ 'gateway' ] = implode(", ", array_map("trim", $gw[ 0 ]));
129 129
 			}
130 130
 		} catch (RuntimeException $e) {
131 131
 			return $result;
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 	public function getNetworkInterfaces(): array {
137
-		$data = [];
137
+		$data = [ ];
138 138
 
139 139
 		foreach ($this->getNetInterfaces() as $interfaceName => $interface) {
140
-			$netInterface = new NetInterface($interfaceName, $interface['up']);
141
-			$data[] = $netInterface;
140
+			$netInterface = new NetInterface($interfaceName, $interface[ 'up' ]);
141
+			$data[ ] = $netInterface;
142 142
 
143
-			foreach ($interface['unicast'] as $unicast) {
144
-				if ($unicast['family'] === self::AF_INET) {
145
-					$netInterface->addIPv4($unicast['address']);
143
+			foreach ($interface[ 'unicast' ] as $unicast) {
144
+				if ($unicast[ 'family' ] === self::AF_INET) {
145
+					$netInterface->addIPv4($unicast[ 'address' ]);
146 146
 				}
147
-				if ($unicast['family'] === self::AF_INET6) {
148
-					$netInterface->addIPv6($unicast['address']);
147
+				if ($unicast[ 'family' ] === self::AF_INET6) {
148
+					$netInterface->addIPv6($unicast[ 'address' ]);
149 149
 				}
150 150
 			}
151 151
 
@@ -154,28 +154,28 @@  discard block
 block discarded – undo
154 154
 			}
155 155
 
156 156
 			try {
157
-				$details = $this->executeCommand('/sbin/ifconfig ' . $interfaceName);
157
+				$details = $this->executeCommand('/sbin/ifconfig '.$interfaceName);
158 158
 			} catch (RuntimeException $e) {
159 159
 				continue;
160 160
 			}
161 161
 
162 162
 			preg_match("/(?<=ether ).*/m", $details, $mac);
163
-			if (isset($mac[0])) {
164
-				$netInterface->setMAC($mac[0]);
163
+			if (isset($mac[ 0 ])) {
164
+				$netInterface->setMAC($mac[ 0 ]);
165 165
 			}
166 166
 
167 167
 			preg_match("/\b[0-9].*?(?=base)/m", $details, $speed);
168
-			if (isset($speed[0])) {
169
-				if (substr($speed[0], -1) === 'G') {
170
-					$netInterface->setSpeed(rtrim($speed[0], 'G') . ' Gbps');
168
+			if (isset($speed[ 0 ])) {
169
+				if (substr($speed[ 0 ], -1) === 'G') {
170
+					$netInterface->setSpeed(rtrim($speed[ 0 ], 'G').' Gbps');
171 171
 				} else {
172
-					$netInterface->setSpeed($speed[0] . ' Mbps');
172
+					$netInterface->setSpeed($speed[ 0 ].' Mbps');
173 173
 				}
174 174
 			}
175 175
 
176 176
 			preg_match("/(?<=\<).*(?=-)/m", $details, $duplex);
177
-			if (isset($duplex[0])) {
178
-				$netInterface->setDuplex($duplex[0]);
177
+			if (isset($duplex[ 0 ])) {
178
+				$netInterface->setDuplex($duplex[ 0 ]);
179 179
 			}
180 180
 
181 181
 			unset($mac, $speed, $duplex);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	}
186 186
 
187 187
 	public function getDiskInfo(): array {
188
-		$data = [];
188
+		$data = [ ];
189 189
 
190 190
 		try {
191 191
 			$disks = $this->executeCommand('df -TPk');
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 			return $data;
194 194
 		}
195 195
 
196
-		$matches = [];
196
+		$matches = [ ];
197 197
 		$pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>[\S]+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';
198 198
 
199 199
 		$result = preg_match_all($pattern, $disks, $matches);
@@ -201,34 +201,34 @@  discard block
 block discarded – undo
201 201
 			return $data;
202 202
 		}
203 203
 
204
-		$excluded = ['devfs', 'fdescfs', 'tmpfs', 'devtmpfs', 'procfs', 'linprocfs', 'linsysfs'];
205
-		foreach ($matches['Filesystem'] as $i => $filesystem) {
206
-			if (in_array($matches['Type'][$i], $excluded, false)) {
204
+		$excluded = [ 'devfs', 'fdescfs', 'tmpfs', 'devtmpfs', 'procfs', 'linprocfs', 'linsysfs' ];
205
+		foreach ($matches[ 'Filesystem' ] as $i => $filesystem) {
206
+			if (in_array($matches[ 'Type' ][ $i ], $excluded, false)) {
207 207
 				continue;
208 208
 			}
209 209
 
210 210
 			$disk = new Disk();
211 211
 			$disk->setDevice($filesystem);
212
-			$disk->setFs($matches['Type'][$i]);
213
-			$disk->setUsed((int)((int)$matches['Used'][$i] / 1024));
214
-			$disk->setAvailable((int)((int)$matches['Available'][$i] / 1024));
215
-			$disk->setPercent($matches['Capacity'][$i]);
216
-			$disk->setMount($matches['Mounted'][$i]);
212
+			$disk->setFs($matches[ 'Type' ][ $i ]);
213
+			$disk->setUsed((int) ((int) $matches[ 'Used' ][ $i ] / 1024));
214
+			$disk->setAvailable((int) ((int) $matches[ 'Available' ][ $i ] / 1024));
215
+			$disk->setPercent($matches[ 'Capacity' ][ $i ]);
216
+			$disk->setMount($matches[ 'Mounted' ][ $i ]);
217 217
 
218
-			$data[] = $disk;
218
+			$data[ ] = $disk;
219 219
 		}
220 220
 
221 221
 		return $data;
222 222
 	}
223 223
 
224 224
 	public function getThermalZones(): array {
225
-		return [];
225
+		return [ ];
226 226
 	}
227 227
 
228 228
 	protected function executeCommand(string $command): string {
229 229
 		$output = @shell_exec(escapeshellcmd($command));
230 230
 		if ($output === null || $output === '' || $output === false) {
231
-			throw new RuntimeException('No output for command: "' . $command . '"');
231
+			throw new RuntimeException('No output for command: "'.$command.'"');
232 232
 		}
233 233
 		return $output;
234 234
 	}
Please login to merge, or discard this patch.