diff options
Diffstat (limited to 'modules-available/statistics/inc/statistics.inc.php')
-rw-r--r-- | modules-available/statistics/inc/statistics.inc.php | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php index d27c1a6a..2a9ca3c9 100644 --- a/modules-available/statistics/inc/statistics.inc.php +++ b/modules-available/statistics/inc/statistics.inc.php @@ -7,7 +7,7 @@ class Statistics private static $machineFields = false; - private static function initFields($returnData) + private static function initFields(int $returnData): string { if (self::$machineFields === false) { $r = new ReflectionClass('Machine'); @@ -25,17 +25,15 @@ class Statistics } /** - * @param string $machineuuid * @param int $returnData What kind of data to return Machine::NO_DATA, Machine::RAW_DATA, ... - * @return \Machine|false */ - public static function getMachine($machineuuid, $returnData) + public static function getMachine(string $machineuuid, int $returnData): ?Machine { $fields = self::initFields($returnData); $row = Database::queryFirst("SELECT $fields FROM machine WHERE machineuuid = :machineuuid", compact('machineuuid')); if ($row === false) - return false; + return null; $m = new Machine(); foreach ($row as $key => $val) { $m->{$key} = $val; @@ -44,12 +42,11 @@ class Statistics } /** - * @param string $ip * @param int $returnData What kind of data to return Machine::NO_DATA, Machine::RAW_DATA, ... * @param string $sort something like 'lastseen ASC' - not sanitized, don't pass user input! - * @return \Machine[] list of matches + * @return Machine[] list of matches */ - public static function getMachinesByIp($ip, $returnData, $sort = false) + public static function getMachinesByIp(string $ip, int $returnData, bool $sort = false): array { $fields = self::initFields($returnData); @@ -74,7 +71,7 @@ class Statistics const OFFLINE_LENGTH = '~offline-length'; const SUSPEND_LENGTH = '~suspend-length'; - public static function logMachineState($uuid, $ip, $type, $start, $length, $username = '') + public static function logMachineState(string $uuid, string $ip, string $type, int $start, int $length, string $username = ''): int { return Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' . " VALUES (:start, :type, :uuid, :clientip, :username, :length)", array( |