Lines 100.00% 11 / 11
Methods 100.00% 3 / 3
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 channel n/a 0 / 0 n/a 0 / 0 0
 phrase n/a 0 / 0 n/a 0 / 0 0
 from 100.00% 4 / 4 100.00% 1 / 1 1
 [Lorekeeper\Server\Event\NamedAfterClass] name 100.00% 6 / 6 100.00% 1 / 1 1
11abstract readonly class NoticeEvent implements Event
12{
13    use NamedAfterClass;
14
15    final public function __construct() {}
16
17    abstract protected static function channel(): string;
18
19    abstract protected static function phrase(): string;
20
21    /** @return Option\Option<static> */
22    #[Override]
23    final public static function from(Message $message): Option\Option
24    {
25        return Notice::text($message, static::channel())->filter(static fn(string $text): bool => str_contains(
26            strtolower($text),
27            static::phrase(),
28        ))->map(static fn(): static => new static());
29    }
30}

From Lorekeeper\Server\Event\NamedAfterClass

7trait 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}