/** * 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; }
/** * {@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; }
/** * {@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); } }
private function getUserFromRow(array $row) : User { return (new User(Uuid::fromBytes($row['user_uuid']), EmailAddress::get($row['email_address']), $row['password'], $row['display_name']))->metaDataSetInsertTimestamp(new \DateTimeImmutable($row['created']))->metaDataSetUpdateTimestamp(new \DateTimeImmutable($row['updated'])); }
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; }
private function getPageBlockFromRow(Page $page, array $row) : PageBlock { return (new PageBlock(Uuid::fromBytes($row['page_block_uuid']), $page, $row['type'], !is_null($row['parameters']) ? json_decode($row['parameters'], true) : [], $row['location'], intval($row['sort_order']), PageStatusValue::get($row['status'])))->metaDataSetInsertTimestamp(new \DateTimeImmutable($row['created']))->metaDataSetUpdateTimestamp(new \DateTimeImmutable($row['updated'])); }
private function getCollectionFromRow(array $row) : ConfigCollection { return (new ConfigCollection(Uuid::fromBytes($row['config_collection_uuid']), $this->typeContainer->getType($row['type']), $row['name']))->metaDataSetInsertTimestamp(new \DateTimeImmutable($row['created']))->metaDataSetUpdateTimestamp(new \DateTimeImmutable($row['updated'])); }
private function getFileFromRow(array $row) : File { $uuid = Uuid::fromBytes($row['file_uuid']); return (new File($uuid, FileNameValue::get($row['name']), FilePathValue::get($row['path']), MimeTypeValue::get($row['mime_type']), $this->getFileStream($uuid)))->metaDataSetInsertTimestamp(new \DateTimeImmutable($row['created']))->metaDataSetUpdateTimestamp(new \DateTimeImmutable($row['updated'])); }
public static function fromBytes($bytes) { return self::fromRamseyUuid(parent::fromBytes($bytes)); }
private function getTokenFromRow(array $row) : Token { return new Token(Uuid::fromBytes($row['token_uuid']), $row['pass_code'], Uuid::fromBytes($row['user_uuid']), new \DateTimeImmutable($row['expires'])); }
public function generate(int $name) : string { $generated = UuidLibrary::fromBytes($this->getIdentifier()); return UuidLibrary::uuid5($generated, $name); }
/** * @param UuidInterface $other * @return int -1, 0 or 1 */ public function compareTo(UuidInterface $other) { $ramseyOther = RamseyUuid::fromBytes($other->getBytes()); return $this->ramseyUuid->compareTo($ramseyOther); }