From 3c9c9b6e992ae41476bb893bfba0ee239e924f3e Mon Sep 17 00:00:00 2001 From: akhil Date: Mon, 11 Jan 2021 13:15:28 +0530 Subject: [PATCH] cs fixed Signed-off-by: akhil --- lib/Controller/ApiController.php | 24 ++++++++++++------------ lib/OperatingSystems/DefaultOs.php | 12 ++++++------ lib/OperatingSystems/FreeBSD.php | 12 ++++++------ lib/SystemStatistics.php | 2 +- tests/lib/SessionStatisticsTest.php | 12 ++++++------ 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index e4d0be99..e6a5b09f 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -79,13 +79,13 @@ public function __construct($appName, SessionStatistics $sessionStatistics) { parent::__construct($appName, $request); - $this->os = $os; - $this->systemStatistics = $systemStatistics; - $this->storageStatistics = $storageStatistics; - $this->phpStatistics = $phpStatistics; + $this->os = $os; + $this->systemStatistics = $systemStatistics; + $this->storageStatistics = $storageStatistics; + $this->phpStatistics = $phpStatistics; $this->databaseStatistics = $databaseStatistics; - $this->shareStatistics = $shareStatistics; - $this->sessionStatistics = $sessionStatistics; + $this->shareStatistics = $shareStatistics; + $this->sessionStatistics = $sessionStatistics; } /** @@ -96,14 +96,14 @@ public function __construct($appName, public function info() { return new DataResponse([ 'nextcloud' => [ - 'system' => $this->systemStatistics->getSystemStatistics(), + 'system' => $this->systemStatistics->getSystemStatistics(), 'storage' => $this->storageStatistics->getStorageStatistics(), - 'shares' => $this->shareStatistics->getShareStatistics() + 'shares' => $this->shareStatistics->getShareStatistics() ], 'server' => [ 'webserver' => $this->getWebserver(), - 'php' => $this->phpStatistics->getPhpStatistics(), - 'database' => $this->databaseStatistics->getDatabaseStatistics() + 'php' => $this->phpStatistics->getPhpStatistics(), + 'database' => $this->databaseStatistics->getDatabaseStatistics() ], 'activeUsers' => $this->sessionStatistics->getSessionStatistics() ]); @@ -113,8 +113,8 @@ public function info() { * @return DataResponse */ public function BasicData(): DataResponse { - $servertime = $this->os->getTime(); - $uptime = $this->formatUptime($this->os->getUptime()); + $servertime = $this->os->getTime(); + $uptime = $this->formatUptime($this->os->getUptime()); return new DataResponse([ 'servertime' => $servertime, diff --git a/lib/OperatingSystems/DefaultOs.php b/lib/OperatingSystems/DefaultOs.php index 0465357a..b8192f4e 100644 --- a/lib/OperatingSystems/DefaultOs.php +++ b/lib/OperatingSystems/DefaultOs.php @@ -147,14 +147,14 @@ public function getNetworkInterfaces() { $result = []; foreach ($interfaces as $interface) { - $iface = []; + $iface = []; $iface['interface'] = basename($interface); - $iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\''); - $iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\''); - $iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\''); + $iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\''); + $iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\''); + $iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\''); if ($iface['interface'] !== 'lo') { $iface['status'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/operstate'); - $iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed'); + $iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed'); if ($iface['speed'] !== '') { $iface['speed'] = $iface['speed'] . 'Mbps'; } else { @@ -169,7 +169,7 @@ public function getNetworkInterfaces() { } } else { $iface['status'] = 'up'; - $iface['speed'] = 'unknown'; + $iface['speed'] = 'unknown'; $iface['duplex'] = ''; } $result[] = $iface; diff --git a/lib/OperatingSystems/FreeBSD.php b/lib/OperatingSystems/FreeBSD.php index 9c4b5a26..e581a8db 100644 --- a/lib/OperatingSystems/FreeBSD.php +++ b/lib/OperatingSystems/FreeBSD.php @@ -153,13 +153,13 @@ public function getNetworkInterfaces() { preg_match_all("/^(?<=(?!\t)).*(?=:)/m", $ifconfig, $interfaces); foreach ($interfaces[0] as $interface) { - $iface = []; + $iface = []; $iface['interface'] = $interface; - $intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']); + $intface = $this->executeCommand('/sbin/ifconfig ' . $iface['interface']); preg_match_all("/(?<=inet ).\S*/m", $intface, $ipv4); preg_match_all("/(?<=inet6 )((.*(?=%))|(.\S*))/m", $intface, $ipv6); - $iface['ipv4'] = implode(' ', $ipv4[0]); - $iface['ipv6'] = implode(' ', $ipv6[0]); + $iface['ipv4'] = implode(' ', $ipv4[0]); + $iface['ipv6'] = implode(' ', $ipv6[0]); if ($iface['interface'] !== 'lo0') { preg_match_all("/(?<=ether ).*/m", $intface, $mac); @@ -168,7 +168,7 @@ public function getNetworkInterfaces() { preg_match("/(?<=\<).*(?=-)/m", $intface, $duplex); $iface['mac'] = implode(' ', $mac[0]); - $iface['speed'] = $speed[0]; + $iface['speed'] = $speed[0]; if (isset($status[0])) { $iface['status'] = $status[0]; @@ -194,7 +194,7 @@ public function getNetworkInterfaces() { } } else { $iface['status'] = 'active'; - $iface['speed'] = 'unknown'; + $iface['speed'] = 'unknown'; $iface['duplex'] = ''; } $result[] = $iface; diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php index f3ce0721..9010e855 100644 --- a/lib/SystemStatistics.php +++ b/lib/SystemStatistics.php @@ -117,7 +117,7 @@ protected function getMemoryUsage() { $return = array_map('intval', $return); if ($return === array_filter($return, 'is_int')) { return [ - 'mem_total' => (int)$return[0]/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' diff --git a/tests/lib/SessionStatisticsTest.php b/tests/lib/SessionStatisticsTest.php index 8a5c468a..43ce6331 100644 --- a/tests/lib/SessionStatisticsTest.php +++ b/tests/lib/SessionStatisticsTest.php @@ -70,11 +70,11 @@ protected function setUp(): void { } private function addDummyValues() { - $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset5Minutes +1, 10); - $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Hour +1, 20); - $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Day +1, 30); - $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset7Days +1, 40); - $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset30Days +1, 50); + $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset5Minutes + 1, 10); + $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Hour + 1, 20); + $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset1Day + 1, 30); + $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset7Days + 1, 40); + $this->addDummyValuesWithLastLogin($this->currentTime - $this->offset30Days + 1, 50); } private function addDummyValuesWithLastLogin($lastActivity, $numOfEntries) { @@ -87,7 +87,7 @@ private function addDummyValuesWithLastLogin($lastActivity, $numOfEntries) { 'login_name' => $query->createNamedParameter('user-' . ($numOfEntries + $i % 2)), 'password' => $query->createNamedParameter('password'), 'name' => $query->createNamedParameter('user agent'), - 'token' => $query->createNamedParameter('token-' . ($i + $numOfEntries*10)), + 'token' => $query->createNamedParameter('token-' . ($i + $numOfEntries * 10)), 'type' => $query->createNamedParameter(0), 'last_activity' => $query->createNamedParameter($lastActivity), 'last_check' => $query->createNamedParameter($lastActivity),