Lines 100.00% 10 / 10
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
MapPads 100.00% 10 / 10 100.00% 1 / 1 10 100.00% 1 / 1
 read 100.00% 10 / 10 100.00% 1 / 1 10
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Server\Event\Map\Helper;
6
7use Lorekeeper\Core\World\Map\MapPad;
8use Lorekeeper\Server\Event\Event;
9use Lorekeeper\Server\Exception\MalformedEventException;
10
11final readonly class MapPads
12{
13    /**
14     * @param class-string<Event> $event
15     *
16     * @throws MalformedEventException
17     */
18    public static function read(string $pad, string $event): MapPad
19    {
20        return match (strtolower($pad)) {
21            'left' => MapPad::Left,
22            'right' => MapPad::Right,
23            'top' => MapPad::Top,
24            'bottom' => MapPad::Bottom,
25            'up' => MapPad::Up,
26            'down' => MapPad::Down,
27            'center' => MapPad::Center,
28            'spawn' => MapPad::Spawn,
29            default => throw new MalformedEventException($event, "unknown pad '{$pad}'"),
30        };
31    }
32}