Lines
92.85%
13 / 14
Methods
75.00%
3 / 4
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| from | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 2 | ||
| summary | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| [Lorekeeper\Server\Event\NamedAfterClass] name | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 1 | ||
| 15 | final readonly class MapMemberOnlyEvent implements Event | |
| 16 | { | |
| 17 | use NamedAfterClass; | |
| 18 | ||
| 19 | public function __construct( | |
| 20 | public MapName $mapName, | |
| 21 | ) {} | |
| 22 | ||
| 23 | /** @return Option\Option<static> */ | |
| 24 | #[Override] | |
| 25 | public static function from(Message $message): Option\Option | |
| 26 | { | |
| 27 | return Notice::text($message, 'warning')->andThen(static function (string $text): Option\Option { | |
| 28 | $match = []; | |
| 29 | ||
| 30 | if (preg_match('/^(\S+) is an membership-only map/i', $text, $match) !== 1) { | |
| 31 | return Option\none(); | |
| 32 | } | |
| 33 | ||
| 34 | return Option\some($match[1]); | |
| 35 | })->map(static fn(string $name): static => new static(new MapName($name))); | |
| 36 | } | |
| 37 | ||
| 38 | #[Override] | |
| 39 | public function summary(): string | |
| 40 | { | |
| 41 | return "{$this->mapName->value} is member-only"; | |
| 42 | } | |
| 43 | } |
From Lorekeeper\Server\Event\NamedAfterClass
| 7 | trait NamedAfterClass | |
| 8 | { | |
| 9 | public function name(): string | |
| 10 | { | |
| 11 | $class = static::class; | |
| 12 | ||
| 13 | return (string) preg_replace( | |
| 14 | '/Event$/', | |
| 15 | replacement: '', | |
| 16 | subject: substr($class, (int) strrpos($class, needle: '\\') + 1), | |
| 17 | ); | |
| 18 | } | |
| 19 | } |