| Total Complexity | 3 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | class Base62UuidIdentity extends AbstractUuidIdentity |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | */ |
||
| 27 | final public static function fromString(string $value) |
||
| 28 | { |
||
| 29 | try { |
||
| 30 | $decoded = \bin2hex((new Base62())->decode($value)); |
||
| 31 | |||
| 32 | static::uuidFromString(\sprintf('%s%s-%s-%s-%s-%s%s%s', ...\str_split($decoded, 4))); |
||
| 33 | } catch (\Exception $exception) { |
||
| 34 | throw new InvalidIdentityException( |
||
| 35 | \sprintf('Provided identity value "%s" is not a valid bas62 UUID.', $value), |
||
| 36 | 0, |
||
| 37 | $exception |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | return new static($value); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Get identity from UUID string. |
||
| 46 | * |
||
| 47 | * @param string $value |
||
| 48 | * |
||
| 49 | * @throws InvalidIdentityException |
||
| 50 | * |
||
| 51 | * @return mixed|static |
||
| 52 | */ |
||
| 53 | final public static function fromUuid(string $value) |
||
| 61 | } |
||
| 62 | } |
||
| 63 |