Lines 100.00% 10 / 10
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ChangeGameSettingCommand 100.00% 10 / 10 100.00% 2 / 2 9 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 toMessage 100.00% 9 / 9 100.00% 1 / 1 8
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Client\Command\Settings;
6
7use Lorekeeper\Client\Command\Command;
8use Lorekeeper\Core\Game\Setting\GameSetting;
9use Override;
10
11final readonly class ChangeGameSettingCommand implements Command
12{
13    public function __construct(
14        private GameSetting $setting,
15        private bool $allowed,
16    ) {}
17
18    #[Override]
19    public function toMessage(): string
20    {
21        $setting = match ($this->setting) {
22            GameSetting::Goto => 'bGoto',
23            GameSetting::Whispers => 'bWhisper',
24            GameSetting::FriendRequests => 'bFriend',
25            GameSetting::PartyInvites => 'bParty',
26            GameSetting::GuildInvites => 'bGuild',
27            GameSetting::Duels => 'bDuel',
28        };
29        $allowed = $this->allowed ? 'true' : 'false';
30
31        return "%xt%zm%cmd%1%uopref%{$setting}%{$allowed}%";
32    }
33}