🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 21:12:30 +01:00
parent c63995a6d5
commit 92a604f988
2 changed files with 51 additions and 18 deletions
+20 -1
View File
@@ -13,6 +13,25 @@ if (! function_exists('setting')) {
}
}
if (! function_exists('isDarkColor')) {
function isDarkColor(?string $hex): bool
{
if (! is_string($hex)) {
return false;
}
$hex = trim($hex);
if (! preg_match('/^#?[0-9a-fA-F]{6}$/', $hex)) {
return false;
}
$hex = ltrim($hex, '#');
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
$luminance = (0.2126 * $r + 0.7152 * $g + 0.0722 * $b) / 255;
return $luminance < 0.5;
}
}
if (! function_exists('hasPermission')) {
function hasPermission(string $permission): string
{
@@ -94,4 +113,4 @@ if (! function_exists('dropForeignKeyIfExists')) {
}
}
}
}
}