Ejemplo n.º 1
0
 /**
  * Encodes a UuidInterface as a string representation of a UUID
  *
  * @param UuidInterface $uuid
  * @return string Hexadecimal string representation of a UUID
  */
 public function encode(UuidInterface $uuid)
 {
     $fields = array_values($uuid->getFieldsHex());
     return vsprintf('%08s-%04s-%04s-%02s%02s-%012s', $fields);
 }
Ejemplo n.º 2
0
 public function encodeBinary(UuidInterface $uuid)
 {
     $components = array_values($uuid->getFieldsHex());
     return hex2bin(implode('', $components));
 }
Ejemplo n.º 3
0
 /**
  * Encodes a UuidInterface as a string representation of a timestamp first COMB UUID
  *
  * @param UuidInterface $uuid
  *
  * @return string Hexadecimal string representation of a GUID
  */
 public function encode(UuidInterface $uuid)
 {
     $sixPieceComponents = array_values($uuid->getFieldsHex());
     $this->swapTimestampAndRandomBits($sixPieceComponents);
     return vsprintf('%08s-%04s-%04s-%02s%02s-%012s', $sixPieceComponents);
 }
Ejemplo n.º 4
0
 /**
  * Encodes a UuidInterface as an optimized binary representation of a UUID
  *
  * @param UuidInterface $uuid
  * @return string Binary string representation of a UUID
  */
 public function encodeBinary(UuidInterface $uuid)
 {
     $fields = $uuid->getFieldsHex();
     $optimized = [$fields['time_hi_and_version'], $fields['time_mid'], $fields['time_low'], $fields['clock_seq_hi_and_reserved'], $fields['clock_seq_low'], $fields['node']];
     return hex2bin(implode('', $optimized));
 }