From 08e8563f94e8b46c08df4c231c838d32365d8f08 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 22 Apr 2025 17:19:39 +0500 Subject: feat: show emote rating --- src/emote.php | 9 ++++++++- src/utils.php | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/emote.php b/src/emote.php index 2fd30c0..1fa0221 100644 --- a/src/emote.php +++ b/src/emote.php @@ -6,9 +6,10 @@ class Emote public string $ext; public string|null $uploaded_by; public int $created_at; + public mixed $rating; public bool $is_in_user_set; - function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set) + function __construct($id, $code, $ext, $created_at, $uploaded_by, $is_in_user_set, $rating) { $this->id = $id; $this->code = $code; @@ -16,6 +17,7 @@ class Emote $this->created_at = $created_at; $this->uploaded_by = $uploaded_by; $this->is_in_user_set = $is_in_user_set; + $this->rating = $rating; } function get_id() @@ -47,4 +49,9 @@ class Emote { return $this->is_in_user_set; } + + function get_rating() + { + return $this->rating; + } } diff --git a/src/utils.php b/src/utils.php index 325603b..a11fa16 100644 --- a/src/utils.php +++ b/src/utils.php @@ -58,7 +58,13 @@ function format_timestamp(int $timestamp_secs) return "$days day" . ($days > 1 ? "s" : ""); } } + function clamp(int $current, int $min, int $max): int { return max($min, min($max, $current)); +} + +function in_range(float $value, float $min, float $max): bool +{ + return $min <= $value && $value <= $max; } \ No newline at end of file -- cgit v1.2.3