Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | final public static function fromString(string $value) |
||
33 | { |
||
34 | if (\strlen($value) !== static::ULID_LENGTH) { |
||
35 | throw new InvalidIdentityException( |
||
36 | \sprintf('Provided identity value "%s" is not a valid ULID.', $value) |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | try { |
||
41 | Ulid::fromString($value); |
||
42 | } catch (\Exception $exception) { |
||
43 | throw new InvalidIdentityException( |
||
44 | \sprintf('Provided identity value "%s" is not a valid ULID.', $value), |
||
45 | 0, |
||
46 | $exception |
||
47 | ); |
||
48 | } |
||
49 | |||
50 | return new static($value); |
||
51 | } |
||
53 |