summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-22 17:19:39 +0500
committerilotterytea <iltsu@alright.party>2025-04-22 17:19:39 +0500
commit08e8563f94e8b46c08df4c231c838d32365d8f08 (patch)
treee13577b2f2d9fbde64203b714516ffd6d78fc780 /src
parent34189e06a88ce4409a2c9652ca26f072c461233e (diff)
feat: show emote rating
Diffstat (limited to 'src')
-rw-r--r--src/emote.php9
-rw-r--r--src/utils.php6
2 files changed, 14 insertions, 1 deletions
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