コード例 #1
0
ファイル: StringCodec.php プロジェクト: 00f100/uuid
 /**
  * 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);
 }
コード例 #2
0
ファイル: GuidStringCodec.php プロジェクト: jacko972/uuid
 public function encodeBinary(UuidInterface $uuid)
 {
     $components = array_values($uuid->getFieldsHex());
     return hex2bin(implode('', $components));
 }
コード例 #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);
 }
コード例 #4
0
ファイル: OrderedTimeCodec.php プロジェクト: ramsey/uuid
 /**
  * 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));
 }