Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
42 | public static function fromString(string $partial): self |
||
43 | { |
||
44 | $result = preg_match('/^<([0-9]+)\.([0-9]+)$/', $partial, $matches); |
||
45 | |||
46 | if ($result !== 1) { |
||
47 | throw new \InvalidArgumentException('String is not a partial'); |
||
48 | } |
||
49 | |||
50 | return new self((int)$matches[1], (int)$matches[2]); |
||
51 | } |
||
52 | } |