Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TimestampFirstCombCodec.php

function TimestampFirstCombCodec::encode

@psalm-return non-empty-string @psalm-suppress MoreSpecificReturnType we know that the retrieved `string` is never empty @psalm-suppress LessSpecificReturnStatement we know that the retrieved `string` is never empty

Overrides StringCodec::encode

File

vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php, line 58

Class

TimestampFirstCombCodec
TimestampFirstCombCodec encodes and decodes COMBs, with the timestamp as the first 48 bits

Namespace

Ramsey\Uuid\Codec

Code

public function encode(UuidInterface $uuid) : string {
    $bytes = $this->swapBytes($uuid->getFields()
        ->getBytes());
    return sprintf('%08s-%04s-%04s-%04s-%012s', bin2hex(substr($bytes, 0, 4)), bin2hex(substr($bytes, 4, 2)), bin2hex(substr($bytes, 6, 2)), bin2hex(substr($bytes, 8, 2)), bin2hex(substr($bytes, 10)));
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal