本文整理匯總了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']));
}