. * * To disable strict typing, comment out the directive below. */ declare(strict_types=1); function score(string $word): int { $score = 0; $chars = mb_str_split(mb_strtoupper($word)); foreach ($chars as $char) { $score += match ($char) { 'D', 'G' => 2, 'B', 'C', 'M', 'P' => 3, 'F', 'H', 'V', 'W', 'Y' => 4, 'K' => 5, 'J', 'X' => 8, 'Q', 'Z' => 10, default => 1, }; } return $score; }