Lines 100.00% 5 / 5
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
JoinMapCommand 100.00% 5 / 5 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 toMessage 100.00% 4 / 4 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Client\Command\Map;
6
7use Lorekeeper\Client\Command\Command;
8use Lorekeeper\Core\Player\PlayerName;
9use Lorekeeper\Core\World\Map\MapName;
10use Lorekeeper\Server\RoomId;
11use Override;
12use Psl\Option\Option;
13
14final readonly class JoinMapCommand implements Command
15{
16    /** @param Option<RoomId> $room */
17    public function __construct(
18        private PlayerName $playerName,
19        private MapName $mapName,
20        private Option $room,
21    ) {}
22
23    #[Override]
24    public function toMessage(): string
25    {
26        return $this->room->proceed(
27            fn(RoomId $room) => "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->mapName}-{$room}%",
28            fn() => "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->mapName}%",
29        );
30    }
31}