@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | class Snapshot |
24 | 24 | { |
25 | 25 | private $procDir; |
26 | - function __construct($procDir='/proc') |
|
26 | + function __construct($procDir = '/proc') |
|
27 | 27 | { |
28 | 28 | $this->procDir = $procDir; |
29 | 29 | $this->readLoadAvg(); |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | private $loadavgData = []; |
34 | 34 | private function readLoadAvg() |
35 | 35 | { |
36 | - $f = fopen($this->procDir . "/loadavg", "r"); |
|
37 | - if ( !$f ) |
|
36 | + $f = fopen($this->procDir."/loadavg", "r"); |
|
37 | + if (!$f) |
|
38 | 38 | throw new Exception("failed to read loadavg"); |
39 | - if ( ($str = fgets($f)) != FALSE ) |
|
39 | + if (($str = fgets($f)) != FALSE) |
|
40 | 40 | { |
41 | 41 | $this->loadavgData = explode(" ", $str); |
42 | 42 | unset($this->loadavgData[3]); |
@@ -53,20 +53,20 @@ discard block |
||
53 | 53 | private $meminfoData = []; |
54 | 54 | private function readMeminfo() |
55 | 55 | { |
56 | - $f = fopen($this->procDir . "/meminfo", "r"); |
|
56 | + $f = fopen($this->procDir."/meminfo", "r"); |
|
57 | 57 | $this->meminfoData = []; |
58 | - if ( !$f ) |
|
58 | + if (!$f) |
|
59 | 59 | throw new Exception("failed to read meminfo"); |
60 | - while ( ($str = fgets($f)) != FALSE ) |
|
60 | + while (($str = fgets($f)) != FALSE) |
|
61 | 61 | { |
62 | 62 | $numMatches = preg_match_all( |
63 | 63 | "/([[:alpha:]()_0-9]+):\s+([0-9]+)(?:\s([[:alpha:]]+)){0,1}/", |
64 | 64 | $str, $entry, PREG_SPLIT_DELIM_CAPTURE); |
65 | - if ( $numMatches > 0 ) |
|
65 | + if ($numMatches > 0) |
|
66 | 66 | { |
67 | 67 | $key = $entry[0][1]; |
68 | 68 | $newEntry = array('value' => $entry[0][2]); |
69 | - if ( isset($entry[0][3]) ) |
|
69 | + if (isset($entry[0][3])) |
|
70 | 70 | { |
71 | 71 | $newEntry['unit'] = $entry[0][3]; |
72 | 72 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | return $this->meminfoData['MemAvailable']; |
95 | 95 | } |
96 | 96 | |
97 | - public function htmlReport($summary=false) |
|
97 | + public function htmlReport($summary = false) |
|
98 | 98 | { |
99 | 99 | $report = "<h2>Host system stats</h2>"; |
100 | 100 | $report .= "<h3>Memory</h3>"; |
101 | - if ( $summary === true ) |
|
101 | + if ($summary === true) |
|
102 | 102 | { |
103 | 103 | $mema = $this->memAvailable(); |
104 | 104 | $memt = $this->memTotal(); |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | $mem = $this->meminfo(); |
123 | 123 | |
124 | 124 | $html = '<table>'; |
125 | - foreach ( $mem as $key => $entry ) |
|
125 | + foreach ($mem as $key => $entry) |
|
126 | 126 | { |
127 | 127 | $html .= '<tr>'; |
128 | 128 | $html .= '<td class="sysinfo_key">'.$key. |
129 | - '</td><td class="sysinfo_value">'.$entry['value'] .'</td>'; |
|
130 | - if ( isset($entry['unit']) ) |
|
129 | + '</td><td class="sysinfo_value">'.$entry['value'].'</td>'; |
|
130 | + if (isset($entry['unit'])) |
|
131 | 131 | { |
132 | 132 | $html .= '<td class="sysinfo_unit">'.$entry['unit'].'</td>'; |
133 | 133 | } |