diff options
author | Patrik Kernstock <info@pkern.at> | 2018-09-03 23:25:17 +0300 |
---|---|---|
committer | Patrik Kernstock <info@pkern.at> | 2018-09-03 23:25:17 +0300 |
commit | a55f3bac57a188a6e0e9bd8bb06ba52f377252dd (patch) | |
tree | 1b0df9cef46b31720644139d41628d2d37076c91 /lib | |
parent | 04b0f72b131b9d0ab3801dccc78fe6824fc41e9d (diff) |
Some code-beautify things
Signed-off-by: Patrik Kernstock <info@pkern.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SystemStatistics.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index d3b0363..9a57249 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -87,7 +87,7 @@ class SystemStatistics { } /** - * get available and free memory including both RAM and Swap + * Get available and free memory including both RAM and Swap * * @return array with the two values 'mem_free' and 'mem_total' */ @@ -100,24 +100,24 @@ class SystemStatistics { //If FreeBSD is used and exec()-usage is allowed if (PHP_OS === 'FreeBSD' && $this->is_function_enabled('exec')) { //Read Swap usage: - exec("/usr/sbin/swapinfo",$return,$status); - if ($status===0 && count($return) > 1) { + exec("/usr/sbin/swapinfo", $return, $status); + if ($status === 0 && count($return) > 1) { $line = preg_split("/[\s]+/", $return[1]); if(count($line) > 3) { - $swapTotal = (int) $line[3]; - $swapFree = $swapTotal- (int) $line[2]; + $swapTotal = (int)$line[3]; + $swapFree = $swapTotal - (int)$line[2]; } } unset($status); unset($return); //Read Memory Usage - exec("/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count",$return,$status); - if ($status===0) { - $return=array_map('intval',$return); + exec("/sbin/sysctl -n hw.physmem hw.pagesize vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $return, $status); + if ($status === 0) { + $return = array_map('intval', $return); if ($return === array_filter($return, 'is_int')) { return [ - 'mem_total' => (int) $return[0]/1024, - 'mem_free' => (int) $return[1]*($return[2]+$return[3]+$return[4])/1024, + 'mem_total' => (int)$return[0]/1024, + 'mem_free' => (int)$return[1] * ($return[2] + $return[3] + $return[4]) / 1024, 'swap_free' => (isset($swapFree)) ? $swapFree : 'N/A', 'swap_total' => (isset($swapTotal)) ? $swapTotal : 'N/A' ]; |