for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* identity (https://github.com/phpgears/identity).
* Identity objects for PHP.
*
* @license MIT
* @link https://github.com/phpgears/identity
* @author Julián Gutiérrez <[email protected]>
*/
declare(strict_types=1);
namespace Gears\Identity;
use Gears\Identity\Exception\InvalidIdentityException;
use PascalDeVink\ShortUuid\ShortUuid;
use Ramsey\Uuid\Uuid;
/**
* Short UUID identity.
class ShortUuidIdentity extends AbstractIdentity
{
* {@inheritdoc}
* @throws InvalidIdentityException
public static function fromString(string $value)
$uuid = (new ShortUuid())->decode($value);
if ($uuid->getVariant() !== Uuid::RFC_4122 || !\in_array($uuid->getVersion(), \range(1, 5), true)) {
throw new InvalidIdentityException(
\sprintf('Provided identifier "%s" is not a valid short UUID', $value)
);
}
return new static($value);