@@ -20,7 +20,9 @@ |
||
20 | 20 | { |
21 | 21 | if (!array_key_exists(WordPressCollector::COLLECTOR_IDENTIFIER, $this->inventory) |
22 | 22 | || !is_array($this->inventory[WordPressCollector::COLLECTOR_IDENTIFIER]) |
23 | - ) return []; |
|
23 | + ) { |
|
24 | + return []; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | $credentials = []; |
26 | 28 |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | $file = new File(); |
27 | 27 | |
28 | - if (!$file->fileExists('/proc/net/dev')) return 0; |
|
28 | + if (!$file->fileExists('/proc/net/dev')) { |
|
29 | + return 0; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $lines = $file->getContents('/proc/net/dev', true); |
31 | 33 | foreach ($lines as $line) { |
@@ -38,12 +40,16 @@ discard block |
||
38 | 40 | } |
39 | 41 | } |
40 | 42 | |
41 | - if (!isset($total)) return 0; |
|
43 | + if (!isset($total)) { |
|
44 | + return 0; |
|
45 | + } |
|
42 | 46 | |
43 | 47 | $history = $memory->getData(self::MEMORY_KEY) ?? []; |
44 | 48 | $lastTotal = end($history); |
45 | 49 | |
46 | - if (!$lastTotal) $lastTotal = 0; |
|
50 | + if (!$lastTotal) { |
|
51 | + $lastTotal = 0; |
|
52 | + } |
|
47 | 53 | |
48 | 54 | if (!empty($history) && $total < $lastTotal) { |
49 | 55 | $memory->addData(self::MEMORY_KEY, $total); |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | if ($metric->isApplicable()) { |
59 | 59 | $lastValue = Memory::getInstance()->getLastData($metric->getName(), -1); |
60 | 60 | $currentValue = $metric->getValue($lastValue); |
61 | - if ($currentValue >= 0) Memory::getInstance()->addData($metric->getName(), $currentValue); |
|
61 | + if ($currentValue >= 0) { |
|
62 | + Memory::getInstance()->addData($metric->getName(), $currentValue); |
|
63 | + } |
|
62 | 64 | $metricResults[$metric->getName()] = max(0, $currentValue); |
63 | 65 | } |
64 | 66 | } |
@@ -72,7 +74,9 @@ discard block |
||
72 | 74 | |
73 | 75 | $file = File::getInstance(); |
74 | 76 | |
75 | - if (!$file->fileExists('/proc/net/dev')) return 0; |
|
77 | + if (!$file->fileExists('/proc/net/dev')) { |
|
78 | + return 0; |
|
79 | + } |
|
76 | 80 | |
77 | 81 | $lines = $file->getContents('/proc/net/dev', true); |
78 | 82 | foreach ($lines as $line) { |
@@ -85,7 +89,9 @@ discard block |
||
85 | 89 | } |
86 | 90 | } |
87 | 91 | |
88 | - if (!isset($total)) return 0; |
|
92 | + if (!isset($total)) { |
|
93 | + return 0; |
|
94 | + } |
|
89 | 95 | |
90 | 96 | $history = $memory->getData(self::MEMORY_KEY) ?? []; |
91 | 97 |
@@ -66,7 +66,9 @@ |
||
66 | 66 | $progressBar->start(); |
67 | 67 | |
68 | 68 | foreach ($this->collectors as $collector) { |
69 | - if ($debugMode) $start = time(); |
|
69 | + if ($debugMode) { |
|
70 | + $start = time(); |
|
71 | + } |
|
70 | 72 | |
71 | 73 | $progressBar->setMessage('collector: ' . $collector->getIdentifier()); |
72 | 74 | $progressBar->display(); |
@@ -32,7 +32,9 @@ |
||
32 | 32 | if ($fileHandler->isDir('/etc/logrotate.d')) { |
33 | 33 | $entries = $fileHandler->scanDir('/etc/logrotate.d'); |
34 | 34 | foreach ($entries as $entry) { |
35 | - if ($entry === '.' || $entry === '..') continue; |
|
35 | + if ($entry === '.' || $entry === '..') { |
|
36 | + continue; |
|
37 | + } |
|
36 | 38 | $fullPath = '/etc/logrotate.d/' . $entry; |
37 | 39 | $logrotateConfigurations[] = $fullPath; |
38 | 40 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // Extract username, UID, and home directory |
31 | - [$username, , $uid, , , $homeDirectory] = array_slice($parts, 0, 6); |
|
31 | + [$username,, $uid,,, $homeDirectory] = array_slice($parts, 0, 6); |
|
32 | 32 | |
33 | 33 | // Only consider regular users (UID >= 1000) with a valid home directory |
34 | 34 | if (!$file->isDir($homeDirectory)) { |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | { |
26 | 26 | if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $this->inventory) |
27 | 27 | || !is_array($this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]) |
28 | - ) return []; |
|
28 | + ) { |
|
29 | + return []; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $configs = $this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]; |
31 | 33 | |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | $file = File::getInstance(); |
60 | 62 | |
61 | 63 | $pluginDir = $documentRoot . 'wp-content/plugins'; |
62 | - if (!$file->isDir($pluginDir)) return []; |
|
64 | + if (!$file->isDir($pluginDir)) { |
|
65 | + return []; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | $plugins = array_diff($file->scanDir($pluginDir), ['.', '..']); |
65 | 69 | $pluginArray = []; |
@@ -67,7 +71,9 @@ discard block |
||
67 | 71 | foreach ($plugins as $pluginFolder) { |
68 | 72 | $path = $pluginDir . '/' . $pluginFolder; |
69 | 73 | |
70 | - if (!$file->isDir($path)) continue; |
|
74 | + if (!$file->isDir($path)) { |
|
75 | + continue; |
|
76 | + } |
|
71 | 77 | |
72 | 78 | $entries = array_diff($file->scanDir($path), ['.', '..']); |
73 | 79 | |
@@ -123,7 +129,9 @@ discard block |
||
123 | 129 | if (isset($urlParts['path'])) { |
124 | 130 | $segments = explode('/', trim($urlParts['path'], '/')); |
125 | 131 | $lastSegment = end($segments); |
126 | - if ($lastSegment) return $lastSegment; |
|
132 | + if ($lastSegment) { |
|
133 | + return $lastSegment; |
|
134 | + } |
|
127 | 135 | } |
128 | 136 | } |
129 | 137 | |
@@ -135,10 +143,14 @@ discard block |
||
135 | 143 | { |
136 | 144 | $url = "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=" . urlencode($slug); |
137 | 145 | $response = @file_get_contents($url); |
138 | - if (!$response) return null; |
|
146 | + if (!$response) { |
|
147 | + return null; |
|
148 | + } |
|
139 | 149 | |
140 | 150 | $pluginData = json_decode($response, true); |
141 | - if (!isset($pluginData['version'])) return null; |
|
151 | + if (!isset($pluginData['version'])) { |
|
152 | + return null; |
|
153 | + } |
|
142 | 154 | |
143 | 155 | $latestVersion = $pluginData['version']; |
144 | 156 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $cmd = 'stat -c%s ' . $escaped; |
51 | 51 | } |
52 | 52 | |
53 | - $output =trim(Runner::getInstance()->run($cmd)->getOutput()); |
|
53 | + $output = trim(Runner::getInstance()->run($cmd)->getOutput()); |
|
54 | 54 | return is_numeric($output) ? (int)$output : 0; |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return trim(Runner::getInstance()->run($cmd)->getOutput()) === '1'; |
61 | 61 | } |
62 | 62 | |
63 | - public function getContents(string $path, bool $asArray = false): string|false|array |
|
63 | + public function getContents(string $path, bool $asArray = false): string | false | array |
|
64 | 64 | { |
65 | 65 | $cmd = 'cat ' . escapeshellarg($path) . ' 2>/dev/null'; |
66 | 66 | $output = Runner::getInstance()->run($cmd)->getOutput(); |
@@ -80,7 +80,7 @@ |
||
80 | 80 | return explode("\n", trim($output)); |
81 | 81 | } |
82 | 82 | |
83 | - public function getFileContents(string $path, bool $asArray = false): string|false|array |
|
83 | + public function getFileContents(string $path, bool $asArray = false): string | false | array |
|
84 | 84 | { |
85 | 85 | return File::getInstance()->getContents($path, $asArray); |
86 | 86 | } |