diff options
Diffstat (limited to 'modules-available/roomplanner/inc/simpleroom.inc.php')
-rw-r--r-- | modules-available/roomplanner/inc/simpleroom.inc.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/modules-available/roomplanner/inc/simpleroom.inc.php b/modules-available/roomplanner/inc/simpleroom.inc.php index 78db6c4a..b4d3e744 100644 --- a/modules-available/roomplanner/inc/simpleroom.inc.php +++ b/modules-available/roomplanner/inc/simpleroom.inc.php @@ -11,6 +11,7 @@ class SimpleRoom extends Room private $tutorIp = false; + /** @var ?string */ private $managerIp = false; public function __construct($row) @@ -21,7 +22,7 @@ class SimpleRoom extends Room 'SELECT machineuuid, clientip, position FROM machine WHERE fixedlocationid = :locationid', ['locationid' => $locationId]); - while ($clientRow = $ret->fetch(PDO::FETCH_ASSOC)) { + foreach ($ret as $clientRow) { $position = json_decode($clientRow['position'], true); if ($position === false || !isset($position['gridRow']) || !isset($position['gridCol'])) @@ -55,27 +56,29 @@ class SimpleRoom extends Room } } - public function machineCount() + public function machineCount(): int { return count($this->machines); } - public function getSize(&$width, &$height) + public function getSize(?int &$width, ?int &$height) { if (empty($this->machines)) { $width = $height = 0; return; } + $minX = $minY = $maxX = $maxY = 0; $this->boundingBox($minX, $minY, $maxX, $maxY); // client's size that cannot be configured as of today $width = max($maxX - $minX + self::CLIENT_SIZE, 1); $height = max($maxY - $minY + self::CLIENT_SIZE, 1); } - public function getIniClientSection(&$i, $offX = 0, $offY = 0) + public function getIniClientSection(int &$i, int $offX = 0, int $offY = 0): string { /* output individual client positions, shift coordinates to requested position */ $out = ''; + $minX = $minY = $maxX = $maxY = 0; $this->boundingBox($minX, $minY, $maxX, $maxY); foreach ($this->machines as $pos) { $i++; @@ -86,10 +89,11 @@ class SimpleRoom extends Room return $out; } - public function getShiftedArray($offX = 0, $offY = 0) + public function getShiftedArray(int $offX = 0, int $offY = 0): ?array { /* output individual client positions, shift coordinates to requested position */ $ret = []; + $minX = $minY = $maxX = $maxY = 0; $this->boundingBox($minX, $minY, $maxX, $maxY); foreach ($this->machines as $pos) { $pos['gridCol'] += $offX - $minX; @@ -100,7 +104,7 @@ class SimpleRoom extends Room return $ret; } - private function boundingBox(&$minX, &$minY, &$maxX, &$maxY) + private function boundingBox(int &$minX, int &$minY, int &$maxX, int &$maxY): void { if ($this->bb !== false) { $minX = $this->bb[0]; @@ -130,12 +134,12 @@ class SimpleRoom extends Room return $this->tutorIp; } - public function isLeaf() + public function isLeaf(): bool { return true; } - public function shouldSkip() + public function shouldSkip(): bool { return empty($this->machines); } |