From 53964f09d9f60ded775d64defe37829ab6c72ee4 Mon Sep 17 00:00:00 2001 From: gravel Date: Mon, 11 Mar 2024 16:56:17 +0000 Subject: [PATCH] refactor: staff count function --- php/servers/servers-rooms.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/php/servers/servers-rooms.php b/php/servers/servers-rooms.php index 963fbb0..87dcc37 100644 --- a/php/servers/servers-rooms.php +++ b/php/servers/servers-rooms.php @@ -399,6 +399,14 @@ )); } + /** + * Return the number of unique Community staff. + * @return int + */ + function get_staff_count(): int { + return count($this->get_staff()); + } + /** * Return duration in seconds since room was created. */ @@ -691,7 +699,7 @@ * @return bool */ public function has_good_staff_rating(): bool { - $staff_count = count($this->get_staff()); + $staff_count = $this->get_staff_count(); return $staff_count >= $this->get_recommended_staff_count(); } @@ -702,7 +710,7 @@ */ public function get_numeric_staff_rating(): float { if (!$this->write || !$this->read) return 2; - return min(2, count($this->get_staff()) / $this->get_recommended_staff_count()); + return min(2, $this->get_staff_count() / $this->get_recommended_staff_count()); } /** @@ -720,7 +728,7 @@ * Estimate whether the Community does not have enough staff. */ public function has_poor_staff_rating(): bool { - return count($this->get_staff()) < $this->get_minimal_staff_count(); + return $this->get_staff_count() < $this->get_minimal_staff_count(); } /**