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

Breadcrumb

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

function StringCodec::getBytes

Returns a byte string of the UUID

3 calls to StringCodec::getBytes()
GuidStringCodec::decode in vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
@inheritDoc
StringCodec::decode in vendor/ramsey/uuid/src/Codec/StringCodec.php
@inheritDoc
TimestampFirstCombCodec::decode in vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
@inheritDoc

File

vendor/ramsey/uuid/src/Codec/StringCodec.php, line 107

Class

StringCodec
StringCodec encodes and decodes RFC 4122 UUIDs

Namespace

Ramsey\Uuid\Codec

Code

protected function getBytes(string $encodedUuid) : string {
    $parsedUuid = str_replace([
        'urn:',
        'uuid:',
        'URN:',
        'UUID:',
        '{',
        '}',
        '-',
    ], '', $encodedUuid);
    $components = [
        substr($parsedUuid, 0, 8),
        substr($parsedUuid, 8, 4),
        substr($parsedUuid, 12, 4),
        substr($parsedUuid, 16, 4),
        substr($parsedUuid, 20),
    ];
    if (!Uuid::isValid(implode('-', $components))) {
        throw new InvalidUuidStringException('Invalid UUID string: ' . $encodedUuid);
    }
    return (string) hex2bin($parsedUuid);
}

API Navigation

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