本文整理汇总了PHP中Rhumsaa\Uuid\Uuid::fromBytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Uuid::fromBytes方法的具体用法?PHP Uuid::fromBytes怎么用?PHP Uuid::fromBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhumsaa\Uuid\Uuid
的用法示例。
在下文中一共展示了Uuid::fromBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUuidToBinary
public function testUuidToBinary()
{
$uuid = Uuid::uuid5(Uuid::NAMESPACE_OID, 1);
$binary = UuidConverter::uuidToBinary($uuid->toString());
$finalUuid = Uuid::fromBytes($binary);
$this->assertSame($uuid->toString(), $finalUuid->toString());
}
示例2: fromBytes
/**
* @param string $bytes
* @return static
*/
public static function fromBytes($bytes)
{
try {
return new static(RamseyUuid::fromBytes($bytes));
} catch (\InvalidArgumentException $e) {
throw InvalidUuid::create(base64_encode($bytes) . ' (base64 encoded)', $e);
}
}
示例3: 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;
}
示例4: getUuidAttribute
/**
* Accessor for uuid attribute
*
* @return string
*/
public function getUuidAttribute()
{
if (!empty($this->attributes['uuid'])) {
return Uuid::fromBytes($this->attributes['uuid'])->toString();
}
}
示例5: fromArray
public static function fromArray(array $teamMemberArray)
{
return new self(Uuid::fromBytes($teamMemberArray['id']), $teamMemberArray['meta_id'], $teamMemberArray['language'], $teamMemberArray['name'], $teamMemberArray['description'], (bool) $teamMemberArray['is_hidden'], \DateTime::createFromFormat('Y-m-d H:i:s', $teamMemberArray['edited_on']), \DateTime::createFromFormat('Y-m-d H:i:s', $teamMemberArray['created_on']));
}