Misc/Fixup

* floating changes
 * condense several switch() into match() constructs
 * fix ucFirst not making the rest of the word lowercase
This commit is contained in:
Sarjuuk
2025-04-02 22:19:52 +02:00
parent 44ff43c113
commit 3078763ec3
5 changed files with 53 additions and 92 deletions

View File

@@ -1488,15 +1488,15 @@ class ItemList extends BaseType
{
$mask = $this->curTpl['scalingStatValue'];
switch ($type)
$mask &= match ($type)
{
case 'stats': $mask &= 0x04001F; break;
case 'armor': $mask &= 0xF001E0; break;
case 'dps' : $mask &= 0x007E00; break;
case 'spell': $mask &= 0x008000; break;
case 'fap' : $mask &= 0x010000; break; // unused
default: $mask &= 0x0;
}
'stats' => 0x04001F,
'armor' => 0xF001E0,
'dps' => 0x007E00,
'spell' => 0x008000,
'fap' => 0x010000, // unused
default => 0x0
};
$field = null;
for ($i = 0; $i < count(Util::$ssdMaskFields); $i++)

View File

@@ -550,22 +550,21 @@ abstract class Util
return Lang::item('ratingString', [$statId, $result, $level]);
}
// default ucFirst doesn't convert UTF-8 chars
public static function ucFirst($str)
// default ucFirst doesn't convert UTF-8 chars (php 8.4 finally implemented this .. see ya in 2027)
public static function ucFirst(string $str) : string
{
$len = mb_strlen($str) - 1;
$first = mb_substr($str, 0, 1);
$rest = mb_substr($str, 1, $len);
$rest = mb_substr($str, 1);
return mb_strtoupper($first).$rest;
return mb_strtoupper($first).mb_strtolower($rest);
}
public static function ucWords($str)
public static function ucWords(string $str) : string
{
return mb_convert_case($str, MB_CASE_TITLE);
}
public static function lower($str)
public static function lower(string $str) : string
{
return mb_strtolower($str);
}