Lines
100.00%
6 / 6
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| inRoom | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| toMessage | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | ||
| 14 | final readonly class JoinMapCommand implements Command | |
| 15 | { | |
| 16 | /** @param Option\Option<MapRoom> $room */ | |
| 17 | public function __construct( | |
| 18 | private PlayerName $playerName, | |
| 19 | public MapName $mapName, | |
| 20 | private Option\Option $room, | |
| 21 | ) {} | |
| 22 | ||
| 23 | public function inRoom(MapRoom $room): self | |
| 24 | { | |
| 25 | return $this->room->isSome() ? $this : new self($this->playerName, $this->mapName, Option\some($room)); | |
| 26 | } | |
| 27 | ||
| 28 | #[Override] | |
| 29 | public function toMessage(): string | |
| 30 | { | |
| 31 | return $this->room->proceed( | |
| 32 | fn(MapRoom $room) => "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->mapName}-{$room}%", | |
| 33 | fn() => "%xt%zm%cmd%1%tfer%{$this->playerName}%{$this->mapName}%", | |
| 34 | ); | |
| 35 | } | |
| 36 | } |