Lines 100.00% 14 / 14
Methods 100.00% 4 / 4
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 from 100.00% 6 / 6 100.00% 1 / 1 1
 summary 100.00% 1 / 1 100.00% 1 / 1 1
 [Lorekeeper\Server\Event\NamedAfterClass] name 100.00% 6 / 6 100.00% 1 / 1 1
16final readonly class QuestTurnInRefusedEvent implements Event
17{
18    use NamedAfterClass;
19
20    public function __construct(
21        public QuestId $quest,
22        public QuestName $name,
23        public string $reason,
24    ) {}
25
26    /** @return Option\Option<static> */
27    #[Override]
28    public static function from(Message $message): Option\Option
29    {
30        return QuestAnswer::read(
31            $message,
32            static::class,
33        )->filter(static fn(QuestAnswer $answer): bool => !$answer->completed)->map(
34            static fn(QuestAnswer $answer): static => new static($answer->quest, $answer->name, $answer->reason),
35        );
36    }
37
38    #[Override]
39    public function summary(): string
40    {
41        return "Could not complete {$this->name->value}: {$this->reason}";
42    }
43}

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}