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()); }
/** * @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); } }
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; }
/** * Accessor for uuid attribute * * @return string */ public function getUuidAttribute() { if (!empty($this->attributes['uuid'])) { return Uuid::fromBytes($this->attributes['uuid'])->toString(); } }
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'])); }