Lines
100.00%
12 / 12
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| from | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 4 | ||
| summary | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [Lorekeeper\Server\Event\NamedAfterClass] name | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 1 | ||
| 14 | final readonly class LoginFailedEvent implements Event | |
| 15 | { | |
| 16 | use NamedAfterClass; | |
| 17 | ||
| 18 | /** @return Option\Option<static> */ | |
| 19 | #[Override] | |
| 20 | public static function from(Message $message): Option\Option | |
| 21 | { | |
| 22 | if (!$message instanceof DelimitedMessage || ($message->data[1] ?? null) !== 'loginResponse') { | |
| 23 | return Option\none(); | |
| 24 | } | |
| 25 | ||
| 26 | if (!in_array($message->data[3] ?? null, ['0', 'false'], strict: true)) { | |
| 27 | return Option\none(); | |
| 28 | } | |
| 29 | ||
| 30 | return Option\some(new static()); | |
| 31 | } | |
| 32 | ||
| 33 | #[Override] | |
| 34 | public function summary(): string | |
| 35 | { | |
| 36 | return 'Login refused'; | |
| 37 | } | |
| 38 | } |
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 | } |