Lines 100.00% 4 / 4
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ClientVersion 100.00% 4 / 4 100.00% 1 / 1 2 100.00% 1 / 1
 demandedIn 100.00% 4 / 4 100.00% 1 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Lorekeeper\Client\Session;
6
7use Lorekeeper\Core\Support\NonEmptyString;
8
9final readonly class ClientVersion extends NonEmptyString
10{
11    public static function demandedIn(string $refusal): ?self
12    {
13        $found = [];
14        if (preg_match('/game version (\d+(?:\.\d+)+)/i', $refusal, $found) !== 1) {
15            return null;
16        }
17
18        return new self($found[1]);
19    }
20}