/**
  * 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;
 }
예제 #2
2
 /**
  * {@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);
     }
 }
예제 #4
0
 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']));
 }
예제 #5
0
 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;
 }
예제 #6
0
 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']));
 }
예제 #7
0
 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']));
 }
예제 #8
0
 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']));
 }
예제 #9
0
 public static function fromBytes($bytes)
 {
     return self::fromRamseyUuid(parent::fromBytes($bytes));
 }
예제 #10
0
 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']));
 }
예제 #11
0
파일: Uuid.php 프로젝트: compufour/uuid
 public function generate(int $name) : string
 {
     $generated = UuidLibrary::fromBytes($this->getIdentifier());
     return UuidLibrary::uuid5($generated, $name);
 }
예제 #12
0
 /**
  * @param UuidInterface $other
  * @return int -1, 0 or 1
  */
 public function compareTo(UuidInterface $other)
 {
     $ramseyOther = RamseyUuid::fromBytes($other->getBytes());
     return $this->ramseyUuid->compareTo($ramseyOther);
 }