本文整理汇总了PHP中Ramsey\Uuid\Uuid::fromBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::fromBytes方法的具体用法?PHP Uuid::fromBytes怎么用?PHP Uuid::fromBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ramsey\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::fromBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertToPHPValue
/**
* {@inheritdoc}
*
* @param string|null $value
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (empty($value)) {
return null;
}
if ($value instanceof Uuid) {
return $value;
}
try {
$uuid = Uuid::fromBytes($value);
} catch (InvalidArgumentException $e) {
throw ConversionException::conversionFailed($value, self::NAME);
}
return $uuid;
}
示例2: convertToDatabaseValue
/**
* {@inheritdoc}
*
* @param mixed $value
* @param AbstractPlatform $platform
*
* @throws ConversionException
*
* @return null|string
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (empty($value)) {
return null;
}
if ($value instanceof Uuid) {
return $value->getBytes();
}
if (Uuid::isValid($value)) {
return Uuid::fromString($value)->getBytes();
}
try {
return Uuid::fromBytes($value)->getBytes();
} catch (\InvalidArgumentException $exception) {
throw OrmTypeConversionException::create()->with($value, self::NAME);
}
}
示例3: convertToPHPValue
/**
* Converts a value from its database representation to its PHP representation of this type.
*
* @param mixed $value The value to convert.
*
* @return Uuid
*/
public function convertToPHPValue($value)
{
if (null === $value) {
return null;
}
if ($value instanceof Uuid) {
return $value;
}
if ($value instanceof MongoBinData) {
$value = $value->bin;
}
try {
$uuid = Uuid::fromBytes($value);
} catch (InvalidArgumentException $e) {
throw ConversionException::conversionFailed($value, self::NAME);
}
return $uuid;
}
示例4: convertStorageValueToIdentifier
private function convertStorageValueToIdentifier($id)
{
if ($this->useBinary) {
try {
return Uuid::fromBytes($id)->toString();
} catch (\Exception $e) {
throw new InvalidIdentifierException('Could not convert binary storage value to UUID.');
}
}
return $id;
}
示例5: fromBytes
public static function fromBytes($bytes)
{
return self::fromRamseyUuid(parent::fromBytes($bytes));
}
示例6: generate
public function generate(int $name) : string
{
$generated = UuidLibrary::fromBytes($this->getIdentifier());
return UuidLibrary::uuid5($generated, $name);
}
示例7: compareTo
/**
* @param UuidInterface $other
* @return int -1, 0 or 1
*/
public function compareTo(UuidInterface $other)
{
$ramseyOther = RamseyUuid::fromBytes($other->getBytes());
return $this->ramseyUuid->compareTo($ramseyOther);
}